I have a script that works correctly on other servers, however on this one server it is operating in the parent directory of where the script is supposed to run. It is only on this one machine and works correct else where.
Script:
Param (
[Parameter(Mandatory=$true)][string]$destinationRoot,
[string]$localPath
)
Get-ChildItem $localPath\* -Include *.bmp, *.svg |
Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-30)} |
ForEach-Object {
$content = $localPath + "\" + $_.Name
$year = (Get-Item $content).LastWriteTime.Year.ToString()
$monthNumber = (Get-Item $content).LastWriteTime.Month
$month = (Get-Culture).DateTimeFormat.GetMonthName($monthNumber)
$destination = $destinationRoot + "\" + $year + "\" + $month
New-Item -ItemType Directory -Force -Path $destination
Move-Item -Path $content -Destination $destination -Force
}
Here is the execution statement from the CMD prompt:
powershell -File "C:\L1_Vision_Images\MoveFiles.ps1" -destinationRoot "\\OB-VM-ME-Data\ME-Data\Archived\LEDTools\MT-1\L1Images\" -localPath "C:\L1_Vision_Images"
Instead of copying the contents in the L1_Vision_Images directory it scans the root of C:.