Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Trouble with passing the name of a file to a variable

$
0
0

Hi

 I'm trying to pass the name of a file to a variable but I get an error that the file cannot be found. However if I use the variable with the actual file name it works.

 

#$FileName = "Test-11-06-2014.xlsx"
$FileName = Get-ChildItem "C:\TEMP\Test*" | Select name
$FilePath = "C:\Temp\" + $FileName
$Title = $FileName.trim(".xlsx")

Thanks,


Viewing all articles
Browse latest Browse all 6937

Trending Articles