My objective is to run the following ‘conda list>[fullPath_based_on_date]’ command in the Anaconda PowerShell Prompt environment:
'conda list>F:\backup\Anaconda\Marc-9700\conda_list_2024-05-08_20-36-37.txt
I have not been able to find a way to get PowerShell to run that command in the Anaconda PowerShell Prompt environment.
But I composed the PowerShell script below hoping that someone will give me some hints about how to fix it, and where I can learn about what I did wrong.
I ran the script inside the Anaconda PowerShell Prompt environment as follows:
(base) PS C:\WINDOWS\system32> & E:\Apps\UtilPS\conda_list_to_txt.ps1
and it generated the error message:
Invoke-Item : Cannot find drive. A drive with the name 'conda list>f' does not exist.
Here’s ‘conda_list_to_txt.ps1’ file’s code:
Get-Date -Format “yyyy-MM-dd_HH-mm-ss”
$DT_now_str = Get-Date -Format “yyyy-MM-dd_HH-mm-ss”
$computer_name = hostname
write-host “`$(computer_name) = ${computer_name}”$dst_fullPath_based_on_date = 'f:\backup\Anaconda\' + $computer_name + '\conda_list_' + $DT_now_str + '.txt' write-host "`$(dst_fullPath_based_on_date) = ${dst_fullPath_based_on_date}" $cmd_conda_list_piped2txt = 'conda list>' + $dst_fullPath_based_on_date write-host "`$(cmd_conda_list_piped2txt) = ${cmd_conda_list_piped2txt}" #Start-Process $cmd_conda_list_piped2txt Invoke-Item $cmd_conda_list_piped2txt
I think “Running commands in the shell - PowerShell | Microsoft Learn” may hold the solution, but I did not understand how to use it properly.
A couple of days ago I posted a similar question on StackOverflow (anaconda - How to use Python's subprocess to run a 'cond list' command and pipe it to a text file - Stack Overflow) but no one had any solutions.
Any suggestions would be much appreciated.
Thanks,
Marc