I have a powerscript script inside a *.bat batch file similiar to:
<# : batch script
@echo off
powershell -nop Invoke-Expression ('$cmdcmdline = ''%CMDCMDLINE%''; $args = @(''%*'' -split '' '')' + [System.IO.File]::ReadAllText('%~f0'))
goto :eof
#>
....
$SourceFile = Get-Item $args[0]
....
Now I call from Windows 10 CommandPrompt the batchscript and passed a filename like
mybatch.bat "D:\mytest folder\myfile with blanks"
Mind the blanks inside folder and filename.
When I running I get the following error:
Get-Item : Cannot find path 'D:\mytest\' because it does not exist.
At line:44 char:23
+ $SourceFile = Get-Item $args[0]
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (D:\mytest:String) [Get-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand
Whats wrong?
How can I access from inside a Powershell script full parameters which are passed correctly from out side enclosed with double quotes?