Remove-Item -Path "c:\Scripts\automatic-updates\" -Recurse -Force $Folder = 'c:\Scripts\automatic-updates' if (Test-Path -Path $Folder) { } else { New-Item $Folder -itemType Directory } $Folder = 'c:\Scripts\automatic-updates-static\Zip' if (Test-Path -Path $Folder) { } else { New-Item $Folder -itemType Directory } $Folder = 'c:\Scripts\automatic-updates-static\Zip\ZipFile' if (Test-Path -Path $Folder) { } else { New-Item $Folder -itemType Directory } $Folder = 'c:\Scripts\automatic-updates-static\Zip\UnZipFiles' if (Test-Path -Path $Folder) { } else { New-Item $Folder -itemType Directory } $Url = "https://gitlab.fourit.cloud/Ivo/automatic-updates-v2/-/archive/main/automatic-updates-v2-main.zip" #Get file name along with extension from url using Split-Path cmdlet $DownloadZipFile = "c:\Scripts\automatic-updates-static\Zip\ZipFile\" + $(Split-Path -Path $Url -Leaf) #Set destination folder path for unzip files $ExtractPath = "c:\scripts\automatic-updates-static\zip\UnZipFiles\" #Ignore SSL error add-type @" using System.Net; using System.Security.Cryptography.X509Certificates; public class TrustAllCertsPolicy : ICertificatePolicy { public bool CheckValidationResult( ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) { return true; } } "@ [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy #Use Invoke-WebRequest cmdlet for above url to save response body and create shell object Invoke-WebRequest -Uri $Url -OutFile $DownloadZipFile $ExtractShell = New-Object -ComObject Shell.Application #PowerShell extract zip file items $ExtractFiles = $ExtractShell.Namespace($DownloadZipFile).Items() #Use ExtractFiles to copy extracted file to destination folder and start a process $ExtractShell.NameSpace($ExtractPath).CopyHere($ExtractFiles) Start-Process $ExtractPath $current_folder = "C:\Scripts\automatic-updates-static\Zip\UnZipFiles\automatic-updates-v2-main\*" $new_folder = "C:\Scripts\automatic-updates" Move-Item -Path $current_folder -Destination $new_folder Get-ChildItem c:\scripts\automatic-updates-static\zip\UnZipFiles -Include *.* -Recurse | ForEach { $_.Delete()} Get-ChildItem C:\Scripts\automatic-updates-static\Zip\ZipFile -Include *.* -Recurse | ForEach { $_.Delete()} .\Start-Remote-task-updatescript.ps1