Yes, as stated, that $envWinDir is not a correct environment variable.
However, # # Well… Let’s just walk through this shall we…
PS D:\Scripts> ‘Define the path to the XML file’
($xmlfile = “D:\Scripts\AppDeployToolkitConfig.xml”)
Test-Path -Path $xmlfile
Define the path to the XML file
D:\Scripts\AppDeployToolkitConfig.xml
True
PS D:\Scripts> 'Creating a new object ’
($oXMLDocument = New-Object System.XML.XMLDocument)
Creating a new object
NodeType : Document
ParentNode :
DocumentType :
Implementation : System.Xml.XmlImplementation
Name : #document
LocalName : #document
…
PS D:\Scripts> ‘load the xml file’
($oXMLDocument.Load($xmlfile))
load the xml file
Exception calling “Load” with “1” argument(s): “There is no Unicode byte order mark. Cannot switch to Unicode.”
At line:2 char:1
PS D:\Scripts> ‘open the logdir per the xml document options path’
($openlogDir = $($oXMLDocument.AppDeployToolkit_Config.Toolkit_Options.Toolkit_LogPath))
Test-Path -Path $openlogDir
open the logdir per the xml document options path
Test-Path : Cannot bind argument to parameter ‘Path’ because it is null.
At line:3 char:17
- Test-Path -Path $openlogDir
-
~~~~~~~~~~~
- CategoryInfo : InvalidData: ( [Test-Path], ParameterBindingValidationException
- FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.TestPathCommand
PS D:\Scripts> ‘Get the Windows directory’
([string]$envWinDir)
Test-Path -Path $envWinDir
Get the Windows directory
Test-Path : Cannot bind argument to parameter ‘Path’ because it is null.
At line:3 char:17
- Test-Path -Path $envWinDir
-
~~~~~~~~~~
- CategoryInfo : InvalidData: ( [Test-Path], ParameterBindingValidationException
- FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.TestPathCommand
PS D:\Scripts> ‘Open the logdir based on options settings’
Test-Path -Path $openlogDir
Open the logdir based on options settings
Test-Path : Cannot bind argument to parameter ‘Path’ because it is null.
At line:2 char:17
- Test-Path -Path $openlogDir
-
~~~~~~~~~~~
- CategoryInfo : InvalidData: ( [Test-Path], ParameterBindingValidationException
- FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.TestPathCommand
########################
So, based on the above, ther are problems well before you start hitting the path stuff.
The reality of your file’s encoding appears to conflict with that specified by
your XML declaration. If your file actually uses one-byte characters, declaring
encoding=“utf-16” won’t change it to use two-byte characters, for example.
Try removing the conflicting encoding from the XML declaration. Replace
with
You may also be able to load the file into a string as a work-around using LoadXML().