Tagged: Moodle

Powershell : Cross reference IDs / UPNs with Azure Active Directory

Recently I needed to check that Moodle was suspending the correct users when allowing full control over accounts to the brilliant bit of Microsoft code plugins suite Office365 integration

As of the October 2021 release it still does odd things when running for the first time with the following setting switched on, if you use Transitive / Nested AD security group to control the access

So I wrote this piece of Powershell script to check each of the returned suspended IDs with whether those were still active in AAD or not.

#Connect-AzureAD
#Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
#C:\ad-test\aad-crossreference.ps1 | Out-File C:\AD-Test\results.txt -width 132

$list = import-csv "c:\AD-Test\Moodle-Azure-AD-sync-run-231221.csv"

$i = 0
foreach($item in $list){

try
	{
	Get-AzureADUser -ObjectId $item.upn | select userprincipalname,accountenabled
	$i++
	} catch

		{
		#Write-Host $_.Exception.Message
		Write-Host -ForegroundColor Yellow $item.upn "not found"
		}
}

Write-Host "Found $i accounts"

The top 3 lines are commented out, they are just should you need them then run them separately at the powershell command prompt. The top two are required to use the script and the 3rd is the line I use to run the script itself, which is saved as aad-crossreference.ps1 and it outputs the result to a file ‘results.txt’.

In the file to check, make sure it starts with a column name of ‘upn’, like so

Hope this helps you out if you ever need to do something similar.

How to remove Moodle 4 site Home

Just a quick tip.

How to remove the site ‘Home‘ for logged in users in Moodle 4, when using the Moodle 4 BOOST theme

/* Hide the Home tab */
.nav-link[href="https://<Your Moodle site>/?redirect=0"] {
  display: none!important;
}

This can be added into the Raw SCSS text field in https://<Your-Moodle-site>/admin/settings.php?section=themesettingboost#theme_boost_advanced

Afterwards our Navigation bar now looks like this

Maybe on the full release of Moodle 4 there might be a toggle to remove it from the GUI as it is not useful to everyone.

Expect more of these nuggets to come as we work to releasing Moodle 4 to our users around Easter 2022