Hope this helps.
First part of what you are doing is you want to select the name done below.
instead of using ls, you could also use get-childitem
get-childitem | where {$_.name -like ‘Te*’ } | Select Name
Instead of using ft, which is format table do another select. Although it appears the result is the same it isn’t. If you was to pipe your command again using Get-Member (GM) you would see that it is not of type ‘FormatStartData’ whereas using select is type ‘FileInfo’ . This does make a difference when you are now tring to pipe it to something else.
So now when you do a Get-Member using Select you will see that you have a ‘Name’ property which you can select so I have just put the first part into a variable - you don’t have to, just one way to do it i guess.
$name = get-childitem | where {$_.name -like ‘Te*’ } | Select Name
$name.name - This as you are referring to is ‘selecting’ the actual name, if you did get a Get-Member on this, you would notice it to be of type String
The next part is mkdir, which is also New-Item however checking the help file on New-Item it seems to take the name property as string or if you want to pipe to it then its by value so we can’t use $name.name, as that is a string
$name | New-Item -ItemType directory
This will error and its nothing to do with Powershell. It has to do with Windows. You cannot have a file and folder with exactly the same name in the same folder i.e File: text.txt and Folder: test.txt - That wont work, however you can force it to override the file by doing a -force
$name | New-Item -ItemType directory -Force
This will work but it will just override the text file. If you was to delete that file and run the command again you would find that it created it as you wanted and as a folder instead.
Hopefully some of that made sense.
Thanks