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
Here is the answer to get just the name from your example. Surround the $i with $( ) and reference the .Name property. The $() will cause it to evaluate the expression.