Reputation: 21
I'm trying to do
Get-Content $env.userprofile\file.txt
but it gives me an error. There's no problem if I use the full path. What's the right way to do this?
Upvotes: 1
Views: 3901
Reputation: 132
Try outputting the value itself, it should be $Env:UserProfile
so :
not .
.
So in this case;
Get-Content "$($Env:UserProfile)\file.txt"
Or you can use Join-Path
rather than just concatenating the string;
Get-Content -Path (Join-Path $Env:UserProfile "file.txt")
Upvotes: 1