Why is it that this command is able to export and create a file in the current path but when I add the Get-Date cmdlet it suddenly fails?
Is the Get-Date cmdlet invoking some type of new environment?
Working command -
Get-Process | Sort-Object WorkingSet64 | Select-Object Name,@{Name='WorkingSet';Expression={($_.WorkingSet64/1MB)}} | Export-Csv -Path "processes64.csv" -Delimiter ","
Command breaks -
$Date = Get-Date -Format "MM-dd-yy-HH:MM"
Get-Process | Sort-Object WorkingSet64 | Select-Object Name,@{Name='WorkingSet';Expression={($_.WorkingSet64/1MB)}} | Export-Csv -Path "processes64$Date.csv" -Delimiter ","
Error message -
Export-Csv : Cannot find drive. A drive with the name 'processes64-06-28-16-15' does not exist. At line:3 char:120
- ... Set64/1MB)}} | Export-Csv -Path "processes64-$Date.csv" -Delimiter ","
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : ObjectNotFound: (processes6406-28-16-15:String) [Export-Csv], DriveNotFoundException
- FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.ExportCsvCommand
I'd just like to either export to a directory on the C drive or to the current working directory..