Trying to write to a file and did the following:
$obj = New-Object System.IO.StreamWriter -ArgumentList join-path $pwd foo.txt
This threw an error
PS C:\code\misc> $obj = New-Object System.IO.StreamWriter -ArgumentList Join-Path $pwd foo.txt
New-Object : A positional parameter cannot be found that accepts argument 'C:\code\misc'.
At line:1 char:18
+ $obj = New-Object <<<< System.IO.StreamWriter -ArgumentList Join-Path $pwd foo.txt
+ CategoryInfo : InvalidArgument: (:) [New-Object], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
So am I forced to use a variable for the join-path part? I know I could use [System.IO.Path]::Combine()
but I just wanted an alternative to that...