Export-csv output issues

I have a need to export the output from a PS script and I am using the export-csv command and its working as it should.

I have been told that the output needs to be dynamic based on the date the PS is run.

Currently I have Export-Csv -Append -Path “\xxxx\PCREPORTING\AD_Cleanup_Reporting\02012019Moved_StaleOU.csv”

Where I now need

Export-Csv -Append -Path “\xxxxxx\PCREPORTING\AD_Cleanup_Reporting%DATE%Moved_StaleOU.csv”

How might I be able to perform this ?

thanks in advance !

Jared

 

Instead of %DATE% you should insert

$(Get-Date -Format ‘yyyyMMdd’)

You can also use date\time formats to create a file sortable date:

PS C:\> 'C:\test\filename_{0:s}.txt' -f (Get-Date) -replace ':'
C\test\filename_2019-02-19T084530.txt