How to concat path and file name for creation and removal
$path=Get-Location
$file="myfile.json"
$path=Join-Path $path $file
#you can cast to a class if the class definition is known
$results = (Get-Content -Path $path | Out-String | ConvertFrom-Json)
foreach($tempObj in $results)
{
$obj_vals=$tempObj|Select-Object -Property *
Write-Host $obj_vals -ForegroundColor Green
}
Konrad Viltersten
A self taught code monkey since the age of 10 when I got my first computer, the coolest Atari 65XE. Later on, a mathematics and computer science student at a university with a lot of side-studies in philosophy, history, Japanese etc. Today, a passionate developer with focus on web related technology from UX, through JS/TS to C# with a touch of SQL. Motto: A lousy programmer knows how to create problems. A good programmer knows how to solve problems. A great programmer knows how to avoid them. (Get the double meaning?) Works at: http://kentor.se Blogs at: http://konradviltersten.wordpress.com Lives at: http://viltersten.somee.com
Updated on June 17, 2022Comments
-
Konrad Viltersten almost 2 years
I'm trying the following.
$woohoo = "c:\temp\shabang" New-Item -ItemType File $woohoo
This creates a file at desired location. However, I'd like to split the
$woo
and$hoo
and go something like this.$woo = "c:\temp" $hoo = "shabang" New-Item -ItemType File ($woo + $hoo)
This doesn't work and I need a hint on how to make it fly. This suggestion nor this on worked out when applied to my situation. Apparently - given path format is unsupported.
Suggestions?
Edit
This is what it looks like:
Edit 2
$woo = "c:\temp"; $hoo= "shabang"; New-Item -ItemType File (Join-Path $woo $hoo)