Import-PWDocuments not working as expected

#Needs 32bit verion of powershell
#This needs the PWPS_DAB module which is installed on the PWZ server. Also, please update the source code in TFS.

Set-ExecutionPolicy -ExecutionPolicy Unrestricted;
Import-Module -Name pwps_dab;

function emptyLogFile {
    $Time = Get-Date;
    "The script ran at $Time" + "`r`n"| out-file c:\ImportPDFDrawingsToPWZ\ImportPDFDrawingsToPWZ.log -Force;
}

function writeLogFile($error) {
    $error| out-file $LogFile  -Append -Force;
}

function sendEmail {
    $body = gc $LogFile;
    $smtp = New-Object Net.Mail.SmtpClient("smtp.dom.in.ads");
    $smtp.Send("email@dom.ain", "first.last@dom.ain", "Import PDF drawings to projectwise ran", $body.ToString);
}

$SecurePassword = ConvertTo-SecureString "pwadmin" -AsPlainText -Force;
New-PWLogin -DatasourceName dom-pwz-dev -UserName pwadmin -Password $SecurePassword;
$rootFolder = "\\dom.in.ads\shared\Applications, Tasks, Public\Drawings\Drawings\";
#Projectwise naming convention for disciplines is different than in drawings drive.
$DrawingTypes = ("000 - Civil", "100 - Conc", "200 - Struct", "300 - Arch", "400 - Mech", "500 - Pipes", "600 - Elect", "700 - Inst", "ISO", "P&ID"), ("CIVIL", "CONC", "STRUC", "ARCH", "MECH", "PIPES", "ELEC", "INST", "ISO", "P&ID");
#$DrawingTypes="P&ID";
$LogFile = "c:\ImportPDFDrawingsToPWZ\ImportPDFDrawingsToPWZ.log";

emptyLogFile;
for ($i = 0; $i -lt $DrawingTypes.Length; $i++) {
    $DTFolder = $rootFolder + $DrawingTypes[1][$i];
    $UnitFolders = Get-ChildItem -Directory -Name $DTFolder;
   
    foreach ($Unit in $UnitFolders) {          
        $drw = $DTFolder + "\" + $Unit;
        $pwz = "Drawings\" + $Unit + "\" + $DrawingTypes[0][$i] + "\";
        try {
            Import-PWDocuments -InputFolder $drw -ProjectWiseFolder $pwz -ExtensionsOfInterest ".pdf" -ErrorAction Stop ;
        }
        catch {
            $ErrorMessage = $_.Exception.Message;
            writeLogFile $ErrorMessage"`r`n";
            
        }
       
    }
  


}
sendEmail;



 

The above script used to work fine. Now, instead of import pdf files, it tries to recreate the entire path in ProjectWise. Has anyone else experienced this issue?

Parents Reply Children