I have 20 reports that come weekly. I have a powershell scrip that will create a folder with the date on it. I would like to create a script that will create a new folder each time it runs and then move all the xlsx file into that new folder. For the folder creation I am using
New-Item -ItemType Directory -Path "S:\***\***\Reporting\Export\$((Get-Date).ToString('yyyy-MM-dd'))"
The road block I am running into is finding a way to specify the new folder as the target path for the moving of files.
Store the newly created directory in a variable use that variable for the Destination
parameter when moving:
$destination = New-Item -ItemType Directory -Path "S:\SOC\Reports\Reporting\Export\$((Get-Date).ToString('yyyy-MM-dd'))"
Move-Item -Path "$SourcePath\*" -Destination $destination