I'm trying to do the following:
$files = Get-ChildItem c:\temp | Select-Object Name
foreach ($i in $files) {
Write-Host "Filename is $i"
}
Sample result:
Filename is @{Name=oracle10204.rsp}
Filename is @{Name=powershell.txt}
How do I get only the following?
Filename is oracle10204.rsp
Filename is powershell.txt
With the -Name switch you can get object names only:
Get-ChildItem c:\temp -Name
If you are adamant about getting your original attempt to work, try replacing
Select-Object Name
with
Select-Object -ExpandProperty Name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With