Removing an Office 365 Tenancy

There may be a reason you wish to totally remove an Office 365 tenancy. In our case, it was that the company we looked after was sold. They wanted the data removed – and quickly.

It is possible now to totally remove a tenancy following these steps:

  1. Remove any licensing from the Office 365 tenancy
  2. Open Powershell
  3. Connect to Azure AD by typing
    Connect-AzureAD

    If this doesn’t work, you may need to install AzureAD. Do this by typing

    Install-Module -Name AzureAD
  4. Once connected, you need to connect to Active Directory or mosl. To do this type
    Connect-MsolService

    If this does not work, you may need to install msol. Do this by typing

    Install-Module -Name Connect-MsolService
  5. Disable dirsync with the following command, if enabled
    Set-MsolDirSyncEnabled -EnableDirSync $false

    This command will take around 30 minutes for all users to become in cloud users

  6. You now need to remove all users and remove them from the recycle bin. Type
    Get-MsolUser | Remove-MsolUser -Force

    Then after waiting 30 minutes or so, type the following

    Get-MsolUser -ReturnDeletedUsers | Remove-MsolUser -RemoveFromRecycleBin -Force

    This command removes the deleted users from the AD recycle bin

  7. The next script will remove all of the enterprise applications in AD. This needs to be done
    $ObjectIds = (Get-AzureADServicePrincipal).ObjectIdFor ($i=0; $i -lt $ObjectIds.Length; $i++){ Remove-AzureADServicePrincipal -objectid $ObjectIds[$i]}
  8. Once these commands are completed, you can check Azure Active Directory by going to https://aad.portal.azure.com. Select Azure Active Directory and try to delete it. You will get something like the following. In this case, once the licenses have expired (these we removed 12 hours ago) you will be able to delete the tenancy.

For more information check out the following links:

RemoteApp Slow after Windows10 1803 update on Server 2012 R2

As the title suggests, after updating Windows 10 computers to 1803, users have reported slow RemoteApp sessions.

You can try disabling Remote FX, but user reports suggest this causes further issues.

The easiest fix is to copy mstsc.exe and mstscax.dll from a 1709 build and replace the files on 1803. We have confirmed this works.

KB4103727 Breaks RDP/Remote Desktop Gateway

This morning we awoke to screams from users not being able to login to our remote desktop servers.

KB4103727 has been released which switches a flag to protect against the CredSSP attack.

The quickest way to fix this to get your users working is to patch your domain controller with the May updates and use group policy to push out a change

You can manually add this to the registry for desktop clients

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters] "AllowEncryptionOracle"=dword:00000002

or via command line

reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters" /f /v AllowEncryptionOracle /t REG_DWORD /d 2

To fix this problem, the May updates need to be installed on all servers and workstations.

More information:

 

Unifi Upgrade – MongoDB does not start

Recently had an issue where upgrading Unifi resulted in MongoDB not starting. Looking to the /var/log/unifi/mongod.log we see:

ERROR: Insufficient free space for journal files
[initandlisten] Please make at least 3379MB available in /usr/lib/unifi/data/db/journal or use --smallfiles
[initandlisten]
[initandlisten] exception in initAndListen: 15926 Insufficient free space for journals, terminating
[initandlisten] dbexit:
[initandlisten] shutdown: going to close listening sockets...
[initandlisten] shutdown: going to flush diaglog...
[initandlisten] shutdown: going to close sockets...
[initandlisten] shutdown: waiting for fs preallocator...
[initandlisten] shutdown: lock for final commit...
[initandlisten] shutdown: final commit...
[initandlisten] shutdown: closing all files...
[initandlisten] closeAllFiles() finished
[initandlisten] journalCleanup...
[initandlisten] removeJournalFiles
[initandlisten] shutdown: removing fs lock...
[initandlisten] dbexit: really exiting now

This is caused by the disk space being too low (under 3.3GB). Taking a look at the filesystem, we can see this is the case:

The type service unifi restart and you should be good to go.

One issue I found from this is that the MongoDB is increasing at a rapid rate. I found an excellent script here which prunes the content in MongoDB for Unifi Controllers.

Unifi 5.6.22 Upgrade Fails to Start Linux ERROR system – [exec] error, rc=255

When upgrading Unifi to 5.6.22, you will find that Unifi does not start on Linux system.

If you see the log files, you will see something like this:

/var/log/unifi/system.log

 <UniFi> ERROR system - [exec] error, rc=255

This is because of a change in the release notes:

The controller will not start if it is set to bind to a privileged port (<1024), as it now runs as a non-root user

To fix this, you must change your config file to use a port outside of the 1024 range. This will be an issue if you’ve changed your port, like me.

  1. Edit /var/lib/unifi/system.properties
  2. Change your ports from
    unifi.http.port=80
    unifi.https.port=443

    to

    unifi.http.port=8080
    unifi.https.port=8443
  3. Now type
    sudo service unifi restart

You should now be able to login to your system using the new ports.

Veeam Backup Fails: VSS Writer Errror 0x800423f4 (Azure AD Connect) – New 31/10/2017

This is an updated post about the issue with Veeam backup failures. The original post is here.

This can be fixed by using the following script and using it as a pre-script before backup.

Script

stop-service -displayname "Microsoft Azure AD Sync"
$FQlogonaccount = Get-WmiObject -Class Win32_Service | ? { $_.displayname -match "Microsoft Azure AD Sync"} | select Startname
$split = $FQlogonaccount.startname.Split("\"[0])
$username = $split[1]
$sqlprocess = Get-WmiObject -Query "Select * from Win32_Process where name = 'sqlservr.exe'" | Select Name, Handle, @{Label='Owner';Expression={$_.GetOwner().User}} | ? { $_.owner -match $username} | select handle | Out-String
$sqlpid= $sqlprocess.Split("`n")[3]
Stop-Process -id $sqlpid -force
start-process -filepath "MsiExec.exe" -argumentlist "/f {6C026A91-640F-4A23-8B68-05D589CC6F18}" -wait
Start-Service -displayname "Microsoft Azure AD Sync"

Steps

  1. Save the script as ps1 file. Put somewhere in the Veeam server.
  2. Right-click the backup task and choose “Edit”
  3. Choose “Guest Processing” -> “Enable application-aware processing” -> “Applications”
  4. Choose the one VM that have AAD tool installed and click “Edit”
  5. Go to “scripts” -> “Require successful script execution”, then locate the script we just created.
  6. Now you’re done.

Patch Tuesday: CVE-2017-11826 Microsoft Office

There is an in-the-wild exploit for Microsoft Office. A patch has been released. This exploit has turned up on Virtus Total today.

A remote code execution vulnerability exists in Microsoft Office software when the software fails to properly handle objects in memory. An attacker who successfully exploited the vulnerability could run arbitrary code in the context of the current user. If the current user is logged on with administrative user rights, an attacker could take control of the affected system. An attacker could then install programs; view, change, or delete data; or create new accounts with full user rights. Users whose accounts are configured to have fewer user rights on the system could be less impacted than users who operate with administrative user rights.

Exploitation of the vulnerability requires that a user open a specially crafted file with an affected version of Microsoft Office software. In an email attack scenario, an attacker could exploit the vulnerability by sending the specially crafted file to the user and convincing the user to open the file. In a web-based attack scenario, an attacker could host a website (or leverage a compromised website that accepts or hosts user-provided content) containing a specially crafted file designed to exploit the vulnerability. An attacker would have no way to force users to visit the website. Instead, an attacker would have to convince users to click a link, typically by way of an enticement in an email or instant message, and then convince them to open the specially crafted file.

Patch Tuesday: KB4041691 & KB4041676 gona ruin your day

Microsoft has made a bit of a boo-boo this week. Hopefully, you haven’t auto approved patches this week.

KB4041691 and KB4041676 were pushed as delta updates through WSUS. First published on Twitter, but now there is a Reddit thread on the issue https://www.reddit.com/r/sysadmin/comments/75o0oq/windows_security_updates_broke_30_of_our_machines/

If you run into this issue, you will need to boot into WinRE and use DISM to remove the update.

With all updates from Microsoft lately, I recommend you lab them first. Don’t take the risk.