I want to have a environment variable that contains the day of week in cmd.exe.
When I run this command I get the result I want.
C:\Users\tisc>powershell (get-date).dayofweek
Friday
Here I'm trying to store the result in a environment variable.
C:\Users\tisc>set dow = powershell (get-date).dayofweek
But when I try to get it I dont get the string as I wanted.
C:\Users\tisc>set dow
DoW=0
dow = powershell (get-date).dayofweek
My goal is to use the variable in a batch file for some backup scripts.
Best Answer
To do it without a temp file you can do:
from the command prompt remove the double %%:
Using
-noprofile
will make it run faster if you have a profile set up for PowerShell.