I created simple script to install FortiClient and put script and setup file in same folder and instead of specifying full path to FortiClientVPN.msi, wanted for script to locate full path of setup folder. Script will run if right click on it and select “Run with PowerShell”. Script will check if current user is Administrator, and if yes, it will elevate Powershell process, it’s equivalent to Run As admin.
Install.ps1:
param([switch]$Elevated)
function Test-Admin {
$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
$currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
if ((Test-Admin) -eq $false) {
if ($elevated) {
# tried to elevate, did not work, aborting
} else {
Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))
}
exit
}
# Restart Process using PowerShell 64-bit
If ($ENV:PROCESSOR_ARCHITEW6432 -eq "AMD64") {
Try {
&"$ENV:WINDIR\SysNative\WindowsPowershell\v1.0\PowerShell.exe" -File $PSCOMMANDPATH
}
Catch {
Throw "Failed to start $PSCOMMANDPATH"
}
Exit
}
# Save the current location and switch to this script's directory.
# Note: This shouldn't fail; if it did, it would indicate a
# serious system-wide problem.
$prevPwd = $PWD; Set-Location -ErrorAction Stop -LiteralPath $PSScriptRoot
try {
# Your script's body here.
# Install FortiClient VPN
Start-Process Msiexec.exe -Wait -ArgumentList '/i FortiClientVPN.msi REBOOT=ReallySuppress /qn'
# ...
$PWD # output the current location
}
finally {
# Restore the previous location.
$prevPwd | Set-Location
}
This script will check if there are any *.xml files created for current day and if yes, it will download it. Service principal is used for Azure authentication
Creating Service principal
In Azure portal, select Azure Active Directory – App registrations
New registration
Give name and click Register
Click on application – Certificates & secrets – Client secrets – New client secret
Create secret and write it
Click overview and write down application ID and tenant ID
Adding contributor role to Service principal on storage account
On storage account select Access control (IAM) – Add – Add role assignment
Select contributor – Next
Assign access to: User, group or service principal, select service principal
Service principal is used for Azure authentication.ApplicationID, service principal password, subscription and tenant ID are stored in encrypted file.
SSL cert is used for encyption/decryption credentials file.
Script checks if C:\Windows\SoftwareDistribution\Download, C:\Windows\Temp,C:\Windows\ccmcache and user profiles folders are empty, if not delete it’s content, delete IIS logs older than 60 days, delete uknown user profiles and run Disk cleanup with all options checked.
This script will clear swap if swap memory usage is more than 80%
#!/bin/bash
# Get total Swap usage
TOTAL_SWAP=$(swapon -s | awk '{print $3}' | grep -v 'Size')
# Convert Total Swap usage from KB to MB
TOTAL_MB=$((TOTAL_SWAP/1024))
# Get 80% of total swap usage
THRESHOLD=$(bc<<<$TOTAL_MB*0.8)
# Get currently used swap
USED_SWAP=$(free -m | awk '/Swap/{print $3}')
# Check if currently used swap is greater than 80% of used swap
if [ $USED_SWAP -gt ${THRESHOLD%.*} ]
then
BEFORE_CLEAR=$(date)
echo "Cleaning swap started on $BEFORE_CLEAR" > /tmp/swap.log
/sbin/swapoff -a
sleep 300
/sbin/swapon -a
AFTER_CLEAR=$(date)
echo "Swap cleared on $AFTER_CLEAR" >> /tmp/swap.log
fi
Had to set sleep, otherwise, getting error Too Many Requests, noticed script executes much faster with try/catch block and will go to sleep if error is thrown.
Needed to synchonize files from Apache web server to different directory but had to include only files which are currently not in use (not being uploaded) from /www-data/ folder to ,/data/map/uploads/ ,remove files from source directory after copying and to create log file only in case of error and filer log to show only actual error and not other statistics
Afer installing fresh Alma linux and setting up network, after trying to update
dnf update getting a lot of 404 errors
Errors during downloading metadata for repository 'appstream':
- Status code: 404 for http://lon.mirror.rackspace.com/almalinux/8/AppStream/x86_64/os/repodata/150138a59aab918ba74498c7297a70a2941383aba246f098a39c17e217b36a7d-filelists.xml.gz (IP: 94.236.26.35)
- Status code: 404 for http://mirror.terrahost.no/almalinux/8/AppStream/x86_64/os/repodata/b1f275be720a2a22d8e9e21c56d4bc574015ac61aaffd569cf01ca6801aa58c7-updateinfo.xml.gz (IP: 185.181.61.25)
- Status code: 404 for http://mirror.reconn.ru/almalinux/8/AppStream/x86_64/os/repodata/868c9c2fa04a6369513cb8d4da34c421e9a08c00d062c85760c358c3a445fd2f-primary.xml.gz (IP: 188.64.168.74)
- Status code: 404 for http://lon.mirror.rackspace.com/almalinux/8/AppStream/x86_64/os/repodata/868c9c2fa04a6369513cb8d4da34c421e9a08c00d062c85760c358c3a445fd2f-primary.xml.gz (IP: 94.236.26.35)
- Status code: 404 for http://mirror.reconn.ru/almalinux/8/AppStream/x86_64/os/repodata/150138a59aab918ba74498c7297a70a2941383aba246f098a39c17e217b36a7d-filelists.xml.gz (IP: 188.64.168.74)
- Curl error (56): Failure when receiving data from the peer for http://mirrors.melbourne.co.uk/almalinux/8/AppStream/x86_64/os/repodata/150138a59aab918ba74498c7297a70a2941383aba246f098a39c17e217b36a7d-filelists.xml.gz [Recv failure: Connection reset by peer]
- Status code: 404 for http://mirrors.gethosted.online/almalinux/8/AppStream/x86_64/os/repodata/868c9c2fa04a6369513cb8d4da34c421e9a08c00d062c85760c358c3a445fd2f-primary.xml.gz (IP: 194.156.79.82)
- Status code: 404 for http://lon.mirror.rackspace.com/almalinux/8/AppStream/x86_64/os/repodata/b1f275be720a2a22d8e9e21c56d4bc574015ac61aaffd569cf01ca6801aa58c7-updateinfo.xml.gz (IP: 94.236.26.35)
- Status code: 404 for https://almalinux.uib.no/8/AppStream/x86_64/os/repodata/150138a59aab918ba74498c7297a70a2941383aba246f098a39c17e217b36a7d-filelists.xml.gz (IP: 129.177.13.60)
- Status code: 404 for http://mirror.cov.ukservers.com/almalinux/8/AppStream/x86_64/os/repodata/b1f275be720a2a22d8e9e21c56d4bc574015ac61aaffd569cf01ca6801aa58c7-updateinfo.xml.gz (IP: 94.229.65.150)
- Status code: 404 for http://mirror.cov.ukservers.com/almalinux/8/AppStream/x86_64/os/repodata/150138a59aab918ba74498c7297a70a2941383aba246f098a39c17e217b36a7d-filelists.xml.gz (IP: 94.229.65.150)
- Status code: 404 for http://mirror.reconn.ru/almalinux/8/AppStream/x86_64/os/repodata/b1f275be720a2a22d8e9e21c56d4bc574015ac61aaffd569cf01ca6801aa58c7-updateinfo.xml.gz (IP: 188.64.168.74)
- Status code: 404 for http://mirrors.coreix.net/almalinux/8/AppStream/x86_64/os/repodata/150138a59aab918ba74498c7297a70a2941383aba246f098a39c17e217b36a7d-filelists.xml.gz (IP: 85.13.241.50)
- Status code: 404 for http://mirror.terrahost.no/almalinux/8/AppStream/x86_64/os/repodata/868c9c2fa04a6369513cb8d4da34c421e9a08c00d062c85760c358c3a445fd2f-primary.xml.gz (IP: 185.181.61.25)
- Status code: 404 for https://almalinux.uib.no/8/AppStream/x86_64/os/repodata/868c9c2fa04a6369513cb8d4da34c421e9a08c00d062c85760c358c3a445fd2f-primary.xml.gz (IP: 129.177.13.60)
- Status code: 404 for http://mirror.cov.ukservers.com/almalinux/8/AppStream/x86_64/os/repodata/868c9c2fa04a6369513cb8d4da34c421e9a08c00d062c85760c358c3a445fd2f-primary.xml.gz (IP: 94.229.65.150)
- Status code: 404 for http://mirrors.melbourne.co.uk/almalinux/8/AppStream/x86_64/os/repodata/b1f275be720a2a22d8e9e21c56d4bc574015ac61aaffd569cf01ca6801aa58c7-updateinfo.xml.gz (IP: 92.63.142.155)
- Status code: 404 for https://almalinux.uib.no/8/AppStream/x86_64/os/repodata/b1f275be720a2a22d8e9e21c56d4bc574015ac61aaffd569cf01ca6801aa58c7-updateinfo.xml.gz (IP: 129.177.13.60)
- Status code: 404 for http://mirrors.gethosted.online/almalinux/8/AppStream/x86_64/os/repodata/b1f275be720a2a22d8e9e21c56d4bc574015ac61aaffd569cf01ca6801aa58c7-updateinfo.xml.gz (IP: 194.156.79.82)
- Status code: 404 for http://almalinux.mirror.katapult.io/8/AppStream/x86_64/os/repodata/b1f275be720a2a22d8e9e21c56d4bc574015ac61aaffd569cf01ca6801aa58c7-updateinfo.xml.gz (IP: 185.53.57.11)
- Status code: 404 for http://mirror.netweaver.uk/almalinux/8/AppStream/x86_64/os/repodata/868c9c2fa04a6369513cb8d4da34c421e9a08c00d062c85760c358c3a445fd2f-primary.xml.gz (IP: 109.169.41.51)
- Status code: 404 for http://mirrors.coreix.net/almalinux/8/AppStream/x86_64/os/repodata/b1f275be720a2a22d8e9e21c56d4bc574015ac61aaffd569cf01ca6801aa58c7-updateinfo.xml.gz (IP: 85.13.241.50)
- Status code: 404 for http://mirror.netweaver.uk/almalinux/8/AppStream/x86_64/os/repodata/b1f275be720a2a22d8e9e21c56d4bc574015ac61aaffd569cf01ca6801aa58c7-updateinfo.xml.gz (IP: 109.169.41.51)
- Status code: 404 for http://mirrors.gethosted.online/almalinux/8/AppStream/x86_64/os/repodata/150138a59aab918ba74498c7297a70a2941383aba246f098a39c17e217b36a7d-filelists.xml.gz (IP: 194.156.79.82)
- Status code: 404 for http://mirror.netweaver.uk/almalinux/8/AppStream/x86_64/os/repodata/150138a59aab918ba74498c7297a70a2941383aba246f098a39c17e217b36a7d-filelists.xml.gz (IP: 109.169.41.51)
- Status code: 404 for http://mirrors.melbourne.co.uk/almalinux/8/AppStream/x86_64/os/repodata/868c9c2fa04a6369513cb8d4da34c421e9a08c00d062c85760c358c3a445fd2f-primary.xml.gz (IP: 92.63.142.155)
- Status code: 404 for http://mirror.terrahost.no/almalinux/8/AppStream/x86_64/os/repodata/150138a59aab918ba74498c7297a70a2941383aba246f098a39c17e217b36a7d-filelists.xml.gz (IP: 185.181.61.25)
- Status code: 404 for http://almalinux.mirror.katapult.io/8/AppStream/x86_64/os/repodata/150138a59aab918ba74498c7297a70a2941383aba246f098a39c17e217b36a7d-filelists.xml.gz (IP: 185.53.57.11)
- Status code: 404 for http://mirrors.coreix.net/almalinux/8/AppStream/x86_64/os/repodata/868c9c2fa04a6369513cb8d4da34c421e9a08c00d062c85760c358c3a445fd2f-primary.xml.gz (IP: 85.13.241.50)
- Status code: 404 for http://almalinux.mirror.katapult.io/8/AppStream/x86_64/os/repodata/868c9c2fa04a6369513cb8d4da34c421e9a08c00d062c85760c358c3a445fd2f-primary.xml.gz (IP: 185.53.57.11)
Error: Failed to download metadata for repo 'appstream': Yum repo downloading error: Downloading error(s): repodata/868c9c2fa04a6369513cb8d4da34c421e9a08c00d062c85760c358c3a445fd2f-primary.xml.gz - Cannot download, all mirrors were already tried without success; repodata/150138a59aab918ba74498c7297a70a2941383aba246f098a39c17e217b36a7d-filelists.xml.gz - Cannot download, all mirrors were already tried without success; repodata/b1f275be720a2a22d8e9e21c56d4bc574015ac61aaffd569cf01ca6801aa58c7-updateinfo.xml.gz - Cannot download, all mirrors were already tried without success
Luckily, i had another Alma Linux system and decided to copy content of repo files from that machine
Mails received from mailchamp.com, were declared as spam. Following errors arrives in mailbox:
Authentication-Results: spf=pass (sender IP is 10.20.30.40)
smtp.mailfrom=something.example.com dkim=pass (signature was verified)
header.d=something.example.com;dmarc=fail action=none
header.from=example.com;compauth=fail reason=601
Received-SPF: Pass (protection.outlook.com: domain of something.example.com
designates 10.20.30.40 as permitted sender) receiver=protection.outlook.com;
client-ip=10.20.30.40; helo=m42-181.mailchimp.com;
Received: from m42-181.mailchimp.com (10.20.30.40) by
DB5EUR03FT015.mail.protection.outlook.com (10.152.20.145) with Microsoft SMTP
Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
15.20.4930.15 via Frontend Transport; Tue, 1 Feb 2022 12:25:07 +0000
DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=something.example.com; q=dns/txt;