none
Need help to find out the issue

    שאלה

  • Hi,

    I have script to move file from one place to another place. The file size will vary from 1GB to 15GB as well. Whenever he script moves larger file then it hung and it's not moving forward even the file moved long back. Then when i press CTRL+C then it's moving forward. Could any one help me to fix this issue.

    The script is below

    $Path = "E$\Notes\Data"
    Net use M: "\\domain.com\app\GIS\Exchg_Mig2"
    $csv = Import-Csv Inputfile.csv -Header @("StagingServerName","StagingServerPath","UPIName")
    Foreach ($row in $csv)
    {
        $ServerName = $row.StagingServerName
        $StagingServerName = [System.Net.Dns]::GetHostByName($ServerName) | Select-Object -ExpandProperty HostName
        Write-Host "The Staging Server Name: `'$StagingServerName`'"  
        $StagingServerPath = $row.StagingServerPath
        Write-Host "The Staging Server Path: `'$StagingServerPath`'"
        $UPIName = $row.UPIName
        Write-Host "The UPI Name: `'$UPIName`'"
        $File = Get-childItem "\\$StagingServerName\$Path\$StagingServerPath"
        Write-Host "The File is: `'$File`'"
        $FileName = $File.Name
        Write-Host "The File Name: `'$FileName`'"
        $NewFileName = "$UPIName"
        Write-Host "The New File Name: `'$NewFileName`'"
        if(Test-path "\\$StagingServerName\E$\Temp")
    {
        write-host "Temp folder is Exists"
        Move-Item -Path "\\$StagingServerName\$Path\$StagingServerPath" -Destination "\\$StagingServerName\E$\Temp"
        Rename-Item "\\$StagingServerName\E$\Temp\$FileName" -NewName "$NewFileName"
    }
        Else
    {
        Write-Host "There is No Temp folder"
        md "\\$StagingServerName\E$\Temp"
        Move-Item -Path "\\$StagingServerName\$Path\$StagingServerPath" -Destination "\\$StagingServerName\E$\Temp"
        Rename-Item "\\$StagingServerName\E$\Temp\$FileName" -NewName "$NewFileName"
    }
    }
    Foreach ($row in $csv)
    {
        $ServerName = $row.StagingServerName
        $StagingServerName = [System.Net.Dns]::GetHostByName($ServerName) | Select-Object -ExpandProperty HostName
        Write-Host "The Staging Server Name: `'$StagingServerName`'"  
        #$FilePath = "\\$StagingServerName\E$\Temp"
        Write-Host "The Staging Server Path: `'$FilePath`'"
        $UPIName = $row.UPIName
        Write-Host "The UPI Name: `'$UPIName`'"
        $NewFileName = "$UPIName"
        Write-Host "The New File Name: `'$NewFileName`'"
       
        $Foldername = get-date -uformat "%m-%d-%y"
        if (test-path "M:\$FolderName")
    {
        write-host "Exists: $FolderName"
        Move-Item -Path "\\$StagingServerName\E$\Temp\$NewFileName" -Destination "M:\$FolderName"
        Write-Host "----------------------------------------------------------------------"
    }
        Else
    {
        write-host "No such folder: $FolderName"
        md "M:\$((get-date).toString('MM-dd-yy'))"
        Move-Item -Path "\\$StagingServerName\E$\Temp\$NewFileName" -Destination "M:\$FolderName"
        Write-Host "----------------------------------------------------------------------"
    }
    }
    Net use M: /d
    Remove-Item -Path E:\inputfile.csv

    The input CSV file is below

    PPTWAN112 cmt\04.23.2012\PPTCON25\roba.nsf 10220859-roba.nsf
    PPTWAN112 cmt\04.23.2012\PPTCON25\basa.nsf 10220859-basa.nsf
    PPTWAN112 cmt\04.23.2012\PPTCON25\Mosr.nsf

    10220859-Mosr.nsf

    יום שישי 04 מאי 2012 17:29

תשובות

כל התגובות