Our IT journal

SMTP – Using Office 365 email account with Postfix relay on Ubuntu

In this case we wanted to use an email account from Office 365 to send emails via postfix, to use as the native mail function for WordPress This is based on Ubuntu 20.04 LTS sudo apt-get update sudo apt-get install postfix mailutils In the menu, just use the default entry (Internet Site) Configuring postfix sudo nano /etc/postfix/ Here we need … Read More

Keep-alive VPN on Windows using PowerShell

Having to rely on Windows VPNs sometimes can be tricky, especially if the VPN tunnel times out. We can use this script for monitoring the tunnel and reconnecting automatically whenever it goes down. We are using the password for the VPN encrypted as seen on this post. $ip = “” $result = gwmi -query “SELECT * FROM Win32_PingStatus WHERE Address … Read More

Configuring NTP on Windows

This will work for most Windows releases, it will force the OS to update its time sync against an NTP server. Run the following commands on a Powershell window:   w32tm /config / /syncfromflags:MANUAL Stop-Service w32time Start-Service w32time After running those commands, force the sync:   w32tm /resync Check w32tm status: w32tm /query /status  

Powershell mass update UPN in AD

Import-Module ActiveDirectory $oldSuffix = “myolddomain.local” $newSuffix = “” $ou = “DC=yourdomain,DC=local” $server = “Hostname” Get-ADUser -SearchBase $ou -filter * | ForEach-Object { $newUpn = $_.UserPrincipalName.Replace($oldSuffix,$newSuffix) $_ | Set-ADUser -server $server -UserPrincipalName $newUpn }  

Use PowerShell to post to a Slack channel with extra args

You need to create an application in Slack with incoming webhooks. Enable the application and confirm your identity. Copy that webhook. Invoke the script with system variables to post extra content for alerts, automation, escalations, etc. $message = “`n” + $args Set-StrictMode -Version Latest $payload = @{ “channel” = “#alerts”; “icon_emoji” = “:inbox_tray:”; “text” = $(Write-output “$message”); “username” = “User”; … Read More

Keep-alive script for Windows VPN connections

$ServerName = “” ##### Script Starts Here ###### foreach ($Server in $ServerName) { if (test-Connection -ComputerName $Server -Count 2 -Quiet ) { write-Host “$Server is alive and Pinging ” -ForegroundColor Green } else { Write-Host “$Server is down.” Write-Host “Disconnecting…” rasdial.exe “Woodside” /DISCONNECT Write-Host “Connecting…” rasdial.exe “Woodside” user vpnpassword } }  

Clean up records on Windows Server DNS using PowerShell

Create a script and execute it on your server. Set up a zone, the Windows Server running the DNS server, a date and the record type. Import-mode DNSServer $zone=”ZONE.TLD” $DNSServer=”DNSHOSTNAME” $beforedate=”12/20/2015″ $recordtype=”A” $records=Get-DnsServerResourceRecord -ZoneName “$zone” -ComputerName $DNSServer | Where-Object {$_.RecordType -eq “$recordtype” -and $_.TimeStamp -lt $beforedate} Foreach ($record in $records) { # Remove the DNS record by filtering Try { … Read More

FQDN access RDWeb by default on Windows Remote Desktop Services

We want our default FQDN to go directly to the RD Web Access webpage. This also helps to remember just the domain name and no extra paths. In order to do a redirect, go to your IIS and put a redirect on your Default Web Site:   This will also redirect all HTTP traffic to HTTPS.  

Retrieving Active Directory user properties via PowerShell

This is all done via Get-ADUser help Get-ADUser   Get-ADUser -identity username -properties *   get-aduser -filter * -properties passwordlastset, passwordneverexpires |ft Name, passwordlastset, Passwordneverexpires With that in mind, lets see a script that exports all data to a CSV while also sorting the objects by Name:   Get-ADUser -filter * -properties passwordlastset, passwordneverexpires | sort-object name | select-object Name, … Read More

Changing the default language and timezone for OWA users in Office 365

Connect to O365 via Powershell We will have to define the Language and Timezone first.   get-mailbox | Set-MailboxRegionalConfiguration -Language -TimeZone   For the timezone, select the middle value:   To apply the desired language and timezone for all the mailboxes on your tenant, use the following syntax: get-mailbox | Set-MailboxRegionalConfiguration -Language 1033 -TimeZone “S.A. Eastern Standard Time”     … Read More