Okay so I'm working in Powershell and am trying to have "write-host" output to a file. Here is the code I'm working with right now
Function CreateNugetPackage {
Param(
[String] $File
)
Process {
$retCode = 0
write-verbose "Getting version of $file..."
$version = (Get-Item $File).VersionInfo.FileVersion
$id = $file.Substring(0, $File.LastIndexof('.'))
$filepath = Get-ChildItem "$File"
$OriginalFilename = (Get-Item $File).VersionInfo.OriginalFilename
write-verbose "$id"
write-verbose "$filepath"
$id > test.txt
write-host $filepath >> test.txt
So the $id generates the name of the file without the extension and what I'm trying to do with the $filepath is have it output the host to the test.txt file. I've tried doing "write-output $filepath >> test.txt" but that didn't work the way I wanted it to. Instead of outputing the host it outputted
Directory: C:\Users\mhopper\Documents\CreateNugetPackage
Mode LastWriteTime Length Name
---- ------------- ------ ----
-ar-- 10/22/2014 9:17 AM 5534208 AjaxControlToolkit.dll
instead of just "C:\Users\mhopper\Documents\CreateNugetPackage\AjaxControlToolkit.dll"
Any help would be appreciated thank you!
$filepath.FullNameas well.Get-ChildItemreturnsFileInfo(orDirectoryInfo) objects which PowerShell formats in a special way.