Question: I am using `PowerShell "(Get-Date).AddDays(-7).ToString('ddMMyyyy')"` in batch script.

I want to use a variable instead of **Get-Date** function. Is it possible?

`ADate` is the variable name!

**Edited:**

As suggested, my script is:

```
For /F UseBackQ %%A In (
    `PowerShell "(Get-Date).AddDays(-7).ToString('ddMMyyyy')"`
) Do Set "Freq=%%A"

```

`Adate` is simple string which comes from the file name, and has a value like `16112016`.

Answer: 
Ok. I got my crystal ball and asked it: "What is the solution here?", and it replied: "Change 

```
PowerShell "(Get-Date).AddDays(-7).ToString('ddMMyyyy')"

```

by

```
PowerShell "(Get-Date -Date '!Adate:~4!-!Adate:~2,2!-!Adate:~0,2!').AddDays(-7).ToString('ddMMyyyy')"

```

", but I have no idea what it is talking about! **`;)`**
You can store the output of the powerShell command into a file and then read that file after that delete that temporary file.

```
    PowerShell "(Get-Date).AddDays(-7).ToString('ddMMyyyy')" >temp.txt
    set /p myVarDate= < date_Shell.txt
    echo Date from Shell %myVarDate%
    del temp.txt 

```