HTTrack Website Copier
Free software offline browser - FORUM
Subject: POWERSHELL Script
Author: Colette Johnson
Date: 02/07/2017 21:46
I'm new to Powershell and trying to use HTTRack to produce a folder with a
scrape of various sites on a monthly basis. 
I can get the POWERSHELL to invoke HTTrack, but HTTrack returns a File Not
Found. I cannot figure out my issue. 

write-output "---------------------Script Start--------------------";
write-output " HTTrack Site Backup Powershell Script"
write-output "-------------------------------------------------------";
# get timestamp
$timestamp = Get-Date -format yyyy_MMM_dd_HHmmss
write-output "The current time is $timestamp."

# invoke HTTrack
write-output "This PowerShell script is invoking HTTrack at $HTTrackPath."

# creates output directory if it doesn't already exist 
$local = Get-Location;

$TargetFolderPath = "C:\PowershellTest\test-$timestamp"
    cd "C:\";
    if((Test-Path $TargetFolderPath) -eq 0)
        mkdir $TargetFolderPath;
        cd $TargetFolderPath;
        write-output "Created Output directory at $TargetFolderPath."        
# end create directory

# set error action preference so errors don't stop and the trycatch 

# set website source
$sourceSite = <>

# Specify EventLog Source
if ([System.Diagnostics.EventLog]::SourceExists("WinHTTrackScript") -eq
$False) {
    New-EventLog -LogName "Network" -Source "WinHTTrackScript"
#End Specify EventLog Source   

# Test that file was created accurately by copying a file from another folder.
This has NOTHING to do with HTTrack- Just a test to make sure path is correct
$copyItem ="c:\WinHTTrack\unrestricted.txt"
Copy-Item  $copyItem $TargetFolderPath
write-output "Test file copied $copyItem to $TargetFolderPath" 
# End Test file creation- This has NOTHING to do with HTTrack- Just a test to
make sure path is correct

    write-output "Downloading data ..."
    invoke-expression "$HTTrackPath $sourceSite -O $TargetFolderPath"   
    write-eventlog -LogName "Network" -Source "WinHTTrackScript" -EventId 1
-Message "Downloaded site for backup"
    # error occurred so lets report it
    write-output "ERROR OCCURRED DURING SCRIPT " $error
    # write an event to the event log
    write-output "Writing FAIL to EventLog"
    write-eventlog -LogName "Network" -Source "WinHTTrack" -EventId 1 -Message
"Download for backup FAILED during execution. $error" -EntryType Error

All articles

Subject Author Date

02/07/2017 21:46

05/01/2024 08:37


Created with FORUM 2.0.11