Select Page

Required Files: None

This script copies the syncro logs, then zips them up using methods available in Powershell 2.0.


#Import Syncro Function so we can upload the syncro log files
Import-Module $env:SyncroModule
## Created by SoHo Integration, LLC
## This script creates a copy of the log files for Syncro, then zips those files, then removes them both after uploading to Syncro
## Please make sure you change the Subdomain
$subdomain = "SUBDOMAINHERE"
Copy-Item "c:\programdata\Syncro\logs" -destination "C:\temp\syncrologs" -Recurse
$srcdir = "C:\temp\syncrologs"
$zipFilename = ""
$zipFilepath = "C:\temp\"
$zipFile = "$zipFilepath$zipFilename"
#Prepare zip file
if(-not (test-path($zipFile))) {
    set-content $zipFile ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
    (dir $zipFile).IsReadOnly = $false  
$shellApplication = new-object -com shell.application
$zipPackage = $shellApplication.NameSpace($zipFile)
$files = Get-ChildItem -Path $srcdir | where{! $_.PSIsContainer}
foreach($file in $files) { 
#using this method, sometimes files can be 'skipped'
#this 'while' loop checks each file is added before moving to the next
    while($zipPackage.Items().Item($ -eq $null){
        Start-sleep -seconds 1
# Attach log files to asset in Syncro
Upload-File -Subdomain $subdomain -FilePath "c:\temp\"
# Cleanup
remove-item "C:\temp\syncrologs" -recurse -Force
remove-item "c:\temp\"