0
votes

When I do the following:

$folderpath = join-path [Environment]::GetFolderPath("Desktop") 'Final'

I get this error:

Join-Path : A positional parameter cannot be found that accepts argument 'Final'. At line:1 char:15 + ... olderpath = join-path [Environment]::GetFolderPath("Desktop") 'Final' ... +
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Join-Path], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.JoinPathCommand

So I have to do the following instead:

$folderpath = [Environment]::GetFolderPath("Desktop")
$folderpath = join-path $folderpath 'Final'

which gives me C:\Users\AMS\Desktop\Final, which is what I want.

Is there a way to do the above in one step?

1

1 Answers

4
votes

Put the environment variable in brackets:

$folderpath = join-path ([Environment]::GetFolderPath("Desktop")) 'Final'