Archive files to a folder

Hi, I have created a script which generates the domain controller inventory in csv format on daily basis and name it same as the current date. For example, if we are running it today, the name would be “DC_29032018.csv”. I am using powershell cmdlets for ARS server (QADUser). At the end of the month we have 28, 30 or 31 files according to the month.

Now I want to move all the csv files generated to a folder called “Archive” at the same path once the month ends. I am able to do it on daily basis but not able to automate it on the basis of month end as some month has 30 days and some has 31. Can someone guide where I am doing mistake?

You could run a once a month script that gets the files in that folder and moves them to a specified folder

New-Item -Path "C:\Temp\$(Get-Date -Format yyyyMM)" -ItemType Directory
Get-ChildItem C:\Temp -File | Move-Item -Destination "C:\Temp\$(Get-Date -Format yyyyMM)"

Can we include this in current script?

For sure, test by running something non destructive 1st so you can set the scheduled task without breaking anything then tailor it to your needs.