Hello guys,
Kind of a weird behavior, when I open a hidden file, then I cannot save it.
Any idea why ?
Here is the code, nothing special.
If I save the result into another file, it works fine.
But if the source file is hidden, and I try to save the modification to the save file, it will fail
I know the work around, removing the hidden attribute from the file, save it, and then set the file as hidden again.
I'm trying to understand with the .Save() method cannot save directly to a hidden file.
Thank you
$gpopath = 'D:\Mes documents\GPO\user3'
$file = 'manifest.xml'
$manifest = join-path $gpopath $file
[xml]$xmlDoc = Get-Content $manifest
$xmlDoc.Backups.BackupInst.GPODisplayName.'#cdata-section' = 'add user3'
$xmlDoc.Save($manifest)
Here is the error:
Exception calling "Save" with "1" argument(s): "Access to the path 'D:\Mes documents\GPO\user3\manifest.xml' is denied."
At line:7 char:1
+ $xmlDoc.Save($manifest)
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException