Quite new to Powershell and scripting/programming and have a pretty basic problem I'm stuck with.
If I have a structure such as this:
Set-Location $PSScriptRoot
And do the following, I get the folders within the Logfiles folder:
$folders = Get-ChildItem -Directory -Path .\Logfiles -Recurse
If I then do the following I can see the first subfolder in "Logfiles"
$folders[0]
But now if I do the following, it seems to be using the "Scripts" folder instead of "Logfiles" as a root folder:
Get-ChildItem $folders[0]
or
Get-ChildItem .\Logfiles\$folders[0]
...(gives a null result)
Does anyone have any information on how directories work within powershell commands? I'm guessing I'm making a very basic mistake with handling the commands!!