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 = "syncrologs.zip" $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) { $zipPackage.CopyHere($file.FullName) #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($file.name) -eq $null){ Start-sleep -seconds 1 } } # Attach log files to asset in Syncro Upload-File -Subdomain $subdomain -FilePath "c:\temp\syncrologs.zip" # Cleanup remove-item "C:\temp\syncrologs" -recurse -Force remove-item "c:\temp\syncrologs.zip" |