Split-Path : Illegal Characters in path

Version 3.9.3 currently receiving the error above on the following line:

[String]$scriptDirectory = Split-Path -Path $InvocationInfo.MyCommand.Definition -Parent

Any help would be appreciated.

Stupid question: what path is causing the error?

Variables: Environment

If (Test-Path -Path 'variable:HostInvocation') {
    $InvocationInfo = $HostInvocation
}
Else {
    $InvocationInfo = $MyInvocation
}
[String]$scriptDirectory = Split-Path -Path $InvocationInfo.MyCommand.Definition -Parent

Can you reply with the results of the Write-log line I’ve added below?

If (Test-Path -Path 'variable:HostInvocation') {
    $InvocationInfo = $HostInvocation
}
Else {
    $InvocationInfo = $MyInvocation
}
Write-log "Path causing issue: [$($InvocationInfo.MyCommand.Definition)]"
[String]$scriptDirectory = Split-Path -Path $InvocationInfo.MyCommand.Definition -Parent

Not providing output. Bad command.

I have seen in other threads where the version of windows has caused issues. Current version is Win10 22H2. Powershell version 5.1 Build 19041 Revision 3031 if that helps

I see from your screenshot that you are not using PSADT or even a PS1 script.

$MyInvocation and $HostInvocation won’t exist then. That is the source of your error.

I am running the powershell script locally to verify it works in Powershell_ISE which is why you see the bluescreen with the red errors. If there is something else I am supposed to be doing I am open to it.

Save your test script, THEN RUN IT in ISE.
Don’t just do “Run Selection”. It won’t work.

FYI:
I was hoping you post the full path to the folder containing Deploy-Application.ps1
Meanwhile, your test script might not help.
PSADT will have logged the error with the bad path.
Find the PSADT log file and post the section pertaining to your command line.

I was able to get this to work. I did not understand how the files interacted, but it is functioning now. Thank you for your help.