Unable to Export-CSV and Export-Excel with file $path

Copper Contributor

Unable to Export-CSV & Export-Excel with file $path   please help me on this. 

 

Able to export with full path Export-excel "c:\123\test.xlsx"

But 

 

Not able to export with below

$path = c:\123\test.xlsx

Export-excel $path 

 

Could not open Excel Package c:\123\test.xlsx
At C:\Program Files\WindowsPowerShell\Modules\ImportExcel\6.1.0\Export-Excel.ps1:546 char:16
+ catch {throw "Could not open Excel Package $path"}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Could not open ...123.xlsx:String) [], RuntimeException
+ FullyQualifiedErrorId : Could not open Excel Package c:\123\test.xlsx

1 Reply

@Rahaman_Syed 

$f = 'D:\Temp\list.csv'
Get-Service | Export-Csv -Path $f