Cannot process argument transformation
Inspired by this post , I created the script below DOSCommands.ps1 Function Invoke-DOSCommands { Param( [Parameter(Position=0,Mandatory=$true)] [String]$cmd, [String]$tmpname = $(([string](Get-Random -Minimum 10000 -Maximum 99999999)) + ".cmd"), [switch]$tmpdir = $true) if ($tmpdir) { $cmdpath = $(Join-Path -Path $env:TEMP -ChildPath $tmpname); } else { $cmdpath = ".\" + $tmpname } Write-Debug "tmpfile: " + $cmdpath Write-Debug "cmd: " + $cmd echo $cmd | Out-File -FilePath $cmdpath -Encoding ascii; & cmd.exe /c $cmdpath | Out-Null } Invoke-DOSCommands "Echo ""Hello World""", -tmpdir $false