Upload files to "/"
This commit is contained in:
parent
581eb856e9
commit
006840669e
12
Start-Remote-task-updatescript.ps1
Normal file
12
Start-Remote-task-updatescript.ps1
Normal file
@ -0,0 +1,12 @@
|
||||
#Load variables
|
||||
. "C:\scripts\automatic-updates-static\Variables.ps1"
|
||||
|
||||
$password = Get-Content "c:\scripts\automatic-updates-static\localpassword.txt" | ConvertTo-SecureString
|
||||
$username = $taskusername
|
||||
$credential = New-Object System.Management.Automation.PSCredential($username,$password)
|
||||
|
||||
$computernames = ($servers)
|
||||
foreach($computername in $computernames)
|
||||
{
|
||||
Invoke-Command -ScriptBlock{Get-ScheduledTask -TaskName "Automatic-Updates-updatescript" | Start-ScheduledTask} -ComputerName $computername -Credential $credential
|
||||
}
|
58
updatescript.ps1
Normal file
58
updatescript.ps1
Normal file
@ -0,0 +1,58 @@
|
||||
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
|
8
variables.ps1
Normal file
8
variables.ps1
Normal file
@ -0,0 +1,8 @@
|
||||
#Place this file in directory: C:\Scripts\automatic-updates-static
|
||||
$userdomain = "domain name"
|
||||
$taskusername = "username" #Service account for running scripts
|
||||
$mailto = "mail-to@example.com" #Where the mail with update notification will be send to
|
||||
$mailfrom = "mail-from@example.com" #Where the mail will be send from
|
||||
$smtpserver = "some.smtpserver.com"
|
||||
$mailusername = "mail-username@example.com"
|
||||
#$servers = #List of servers to be updated after DC. Example = "cust-tst-ts01","cust-tst-ts02"
|
BIN
ver20220805
Normal file
BIN
ver20220805
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user