Managing Local User Profiles Buildup

Powershell
Obviously there's a GPO for this... ...but it's a bit rubbish and the computer needs a restart for it to ever work and I also didn't want to wipe out Staff Local User Profiles, I only cared about getting rid of Old Student User Profiles, I do this to ensure there's enough disk space on the machines, luckily student usernames are all numbers so this was easy to do. Get-WMIObject -Class Win32_UserProfile | Where-Object {(!$_.Special) -and ($_.ConvertToDateTime($_.LastUseTime) -lt (Get-Date).AddDays(-3)) -and ($_.LocalPath.Split('\')[-1] -match '^\d+$') } | Remove-WmiObject By using PowerShell, we can query WMI and delete old profiles on the machine. The following bit of PowerShell above will ensure special user profiles are not deleted and only delete profiles that are older than 3 days old, obviously you can change this…
Read More

Staff member user account creation script

Powershell, Windows
Sharing is caring, right? Here is a powershell script I wrote that creates new users based on their First name and surname, checks to see if a username exists from their first name in AD, if it does append the first letter from their surname and use that as their username, if that exists, append the next letter, etc. I also have logic to set and create the user's home drive, add the account to the correct security groups, create a remote mailbox, begin a delta sync on Azure AD Connect, log to a text file for audit purposes and print off a word document to pass on details to new user. [code language="powershell"] #New Staff Account Creation Script, Created by NCK - Last Revised 14/05/2018</code> #DECLARED VARIABLES $Colours =…
Read More

Speed up your OSD time

sccm
When looking at decreasing the time it takes for your OSD. There are three things you will want to look at. These are, configuring dynamic variables to specify what your reboot delay should be on steps that require a reboot, the smsĀ agent host service and power management settings. By default, your reboots will take 1 minute so this is theoretically 2-3 minutes between steps where you have specified a reboot. The SMS agent host service is set by default as a delayed startup so this eats into time for your OSD too and lastly power management is set to default, you'll want this on high performance. First create a step in your task sequence and choose Set Dynamic Variables, in this I have specified the 4 variables, there are probably…
Read More
Can’t connect to SQL instance using Windows Authentication

Can’t connect to SQL instance using Windows Authentication

Windows
I had an odd issue at work where I could not connect to a SQL server using Windows authentication even though I had the authentication set to mixed mode. I was able to logon with the SQL authentication details but not with Windows authentication. I was presented with the following message - "The target principal name is incorrect. Cannot generate SSPI context." When looking into this it turned out that the SPNs were registered to a user object that did not run the service on the host of where the SQL Server was running. I use service accounts for SQL server, this one named SCCM-SQLSRV and this did not have the SPNs registered to it. To find out the user object/computer object that the SPNs are registered to you must…
Read More
Setting up a reverse proxy using nginx for your FREENAS jails

Setting up a reverse proxy using nginx for your FREENAS jails

FREENAS, GNU/Linux, nginx
I am a big user of FREENAS and the goal behind this was to have one domain and to redirect the requests for my jails using, "jails/sickrage", "jails/sonarr", etc... In order to do this, what you need to do is get an nginx server up and running. For this, I simply created a Linux Jail template and installed nginx. This post makes the assumptions that you are using FREENAS, you are proficient in using vi or nano and that your jails are properly configured to handle reverse proxies, if not, I can do a guide on this in the future for the things you'll need to configure for them to work correctly and you know how to set up a custom jail. On your nginx server, locate the nginx.conf file.…
Read More
Chromecast devices not discoverable on Linux

Chromecast devices not discoverable on Linux

GNU/Linux
The documentation from Google indicates that the Google Cast extension is not supported in Linux, but it actually does work. In order for it to work you must configure iptables to allow the uPnP/SSDP traffic used by the Google Cast browser extension to discover the Chromecast Devices. The browser will send a multicast UDP packet from the local IP and an ephemeral (random) port to 239.255.255.250 port 1900. The ChromeCast device will respond with a unicast UDP packet from the ChromeCast device's IP and another ephemeral port to the source IP/port of the multicast packet. Note that this is slightly different than most other UPnP devices, which will usually respond with a unicast UDP packet from port 1900 instead of an ephemeral port. You will need to add a rule…
Read More
How to properly end a KDE session from shell without root privileges

How to properly end a KDE session from shell without root privileges

GNU/Linux
To end a KDE session from the shell without root privileges what you can do is send a logout command via dbus to KDE. This then should terminate the session. The command is as follows: qdbus org.kde.ksmserver /KSMServer logout 0 0 0 dbus is a messaging system that lets applications communicate with each other, and the qdbus command is a utility for sending dbus messages to applications. Applications register with dbus, and the ksmserver part of KDE is the session manager - it looks after who is logged in. So we are sending a message to ksmserver to the /KSMServer interface and telling it to logout. The message we are sending is the exact same message that is sent to KSM when you click on the logout icon on your…
Read More