Private/Compress-uAArchive.ps1

Function Compress-uAArchive{
    [CmdletBinding(SupportsShouldProcess = $False)]
    PARAM
    (
        [Parameter(Mandatory = $True, Position = 0)]
        $SourceDir,
        
        [Parameter(Mandatory = $True, Position = 1)]
        $ZipFilename,
        
        [Parameter(Mandatory = $True, Position = 2)]
        $ZipFilepath
    )

    $ZipFile = Join-Path $ZipFilepath $ZipFilename

    #Prepare zip file
    if(-not (test-path($ZipFile))) {
        set-content $ZipFile ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
        (Get-ChildItem $ZipFile).IsReadOnly = $false  
    }

    $shellApplication = new-object -com shell.application
    $zipPackage = $shellApplication.NameSpace($ZipFile)
    $files = Get-ChildItem -Path $SourceDir

    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($null -eq $zipPackage.Items().Item($file.name)){
            Start-sleep -seconds 1
        }
    }
}
# SIG # Begin signature block
# MIIRVgYJKoZIhvcNAQcCoIIRRzCCEUMCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCBIzKMDSx2RaqtR
# W++II9n9bf06IHgEQzThbBsg9ZMRp6CCDW0wggZyMIIEWqADAgECAghkM1HTxzif
# CDANBgkqhkiG9w0BAQsFADB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
# EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8G
# A1UEAwwoU1NMLmNvbSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTAe
# Fw0xNjA2MjQyMDQ0MzBaFw0zMTA2MjQyMDQ0MzBaMHgxCzAJBgNVBAYTAlVTMQ4w
# DAYDVQQIDA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