All posts by incutubus

How to connect to an AzureAD joined computer with Remote Desktop

When trying to connect using Remote Desktop Connection (RDP) to a computer which is AzureAD joined, one will not be successful as it will fail to connect. To successfully connect, one should first open the Remote Desktop Connection, enter the details of the devices and save the save your connection settings to a .rdp file.

To do this, follow the instructions below.

Open the Remote Desktop Connection program.
Enter the IP Address or computer name to connect to.
Click the Save As button at the bottom of the screen.
Save it someplace convenient as we need to edit it.

In the next part we will be editing the .rdp file we saved using notepad or any text editor.

Go to the end of the file, add the following lines:

enablecredsspsupport:i:0
authentication level:i:2

Save the file and close.

Now, double clicking the modified .rdp file and login using the format:

AzureAD\YourFullUsername

You will be able to remote connect to the machine.

Microsoft 365 online archive never starts

When having a user mailbox, you enable the online archive mailbox and set the archive policy, but the emails never move from the user mailbox to the online archive. You run the full crawl with PowerShell but nothing happens.

The problem could be that the Retention Hold is enabled. This can be fixed by running the below.

Get-Mailbox "<email address of user>" | Select RetentionHoldEnabled

This will show if the feature is enabled. Run the following command to remove the Retention Hold flag.

Set-Mailbox "<email address of user>" -RetentionHoldEnabled $false

Once this is complete, run the following command to re-run the job.

Start-ManagedFolderAssistant -Identity "<email address of user>" -FullCrawl

After some time you should see the archive being populated.

Fix Remote server returned ‘550 5.7.520 Access denied, Your organization does not allow external forwarding

This is a security feature from Microsoft 365 where it will block emails from being forwarded outside the tenant. If you get such a message, this means that the recipient has forwarding set outside its tenant. To allow this feature, follow the below guide.

Open the Office 365 Admin Center and click on Security.

Under Email & Collaboration, click on Policies & Rules.

Click on Threat Policies.

Click on Anti-Spam under Policies.

Click on Anti-spam outbound policy (Default).
Scroll down and click on Edit protection settings.
Under Forwarding Rules, change the Automatic forwarding rules from Automatic – System-controlled to On – Forwarding is enabled.
Click on Save.

Changing Timezone from command line

It would be the case that you would need to change the time zone on the server but from the Time & Date option, it would be greyed out due to policy. There is a workaround for changing the timezone using the Command Prompt as Administrator.

Type tzutil /g to get the current time zone.

Type tzutil /l to list the available time zones.

Use tzutil /s "<timezone name>" to change the desired timezone.

 

Fix Remote Desktop Licensing Mode is not configured

Having fully installed Remote Desktop Services (RDS) on a server with the RD Connection Broker and RDS licensing set per user and everything is working with a valid license.

After some time you notice a popup when you connect saying,

Remote Desktop licensing mode is not configured
Remote Desktop Services will stop working in 104 days. On the RD Connection Broker server, use Server Manager to specify the Remote Desktop licensing mode and the license server.

When you open the RD Licensing Diagnoser, you will be prompted with an error saying, The licensing mode for the Remote Desktop Session Host server is not configured.

From the Server Manager under Configure the Deployment and RD licensing, all seem to be configured well.

Open a PowerShell as Administrator on the server and run the following command

$obj = gwmi -namespace "Root/CIMV2/TerminalServices" Win32_TerminalServiceSetting
$obj.GetSpecifiedLicenseServerList()

This will show a parameter called SpecifiedLicenseServerList which would be empty as below.

To populate the parameter, use the following command

$obj.SetSpecifiedLicenseServerList("<full fqdn server name>")

After this is done, the RD Licensing Diagnoser parameter should not report any errors. It is suggested to restart the server after this change.

Alternatively, one could do this with registry with the following PowerShell script

# Specify the RDS licensing type: 2 - Per Device CAL, 4 - Per User CAL
$RDSCALMode = 4
$RDSlicServer = "<server full fqdn name>"
# Set the server name and type of licensing in the registry
New-Item "HKLM:\SYSTEM\CurrentControlSet\Services\TermService\Parameters\LicenseServers"
New-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\TermService\Parameters\LicenseServers" -Name SpecifiedLicenseServers -Value $RDSlicServer -PropertyType "MultiString"
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\RCM\Licensing Core\" -Name "LicensingMode" -Value $RDSCALMode

Unifi Controller Start-up Failed

When starting up your UniFi controller on your server, you might be prompted with the error saying “Start-up failed” as the screenshot below.

Some might manage to see that the application says that Port 8443 is in use by another application. Some CCTV applications or other web applications installed on the server would use the same port.

Here you would have two choices, you can uninstall the conflicting application or just change the port of the UniFi controller.

To change the port of the UniFi controller, you need to open the system.properties file from C:\Users\<user name>\Ubiquiti UniFi\data.

Remove the hash from the below lines and change the port to 8445 and both lines should be as below.

unifi.https.port=8445
portal.https.port=8445

Save the file and close Notepad. Open the UniFi Controller and the issue will be resolved and the service will start with no issues.

 

 

PGAdmin, cannot register new server Instance Server at, is not persisted

You might encounter the following error while registering a new server in PG Admin.

Instance '<Server at <guid>>' is not persisted.

The issue is mostly due to uninstalling and re-installing PG Admin or installing a different version of PG Admin.

The resolution would be the following.

  • Close PGAdmin
  • Browse to C:\Users\<your user>\AppData\Roaming
  • Delete the folder PGAdmin
  • Open PGAdmin

This will resolve the issue

SQL How to empty all tables in a database

You might need to purge all the data in all the tables in a particular database. For this we can use the following script.

USE <database name>
DECLARE @TableName AS VARCHAR(MAX)
DECLARE table_cursor CURSOR
FOR
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
AND TABLE_NAME LIKE '%_Partition%'
OPEN table_cursor
FETCH NEXT FROM table_cursor INTO @TableName
WHILE @@FETCH_STATUS = 0
BEGIN
DECLARE @SQLText AS NVARCHAR(4000)
SET @SQLText = 'TRUNCATE TABLE ' + @TableName
EXEC sp_executeSQL @SQLText
FETCH NEXT FROM table_cursor INTO @TableName
END
CLOSE table_cursor
DEALLOCATE table_cursor

Install Windows 10 or 11 with a local user

On Windows 10 and Windows 11, you will be forced to log in the machine with a Microsoft Account. There is a way to bypass this and use only a local account without having to create a Microsoft Account to set it up.

Once you get to this screen, press Shift and F10

This will open a Command Prompt. Enter ipconfig /release and press the Enter key. This will release the IP address and disconnect the computer from the internet.

Close the Command Prompt window. Go back from the arrow on the top left and you will be asked to create a local user.

Like this you will not be forced to log in with a Microsoft Account.

 

Fix: Storage Replica warning Events 10448 Storage Replica has failed an application IO

When checking the logs of the Storage Replica on a Windows Server 2016, 2019 or 2022, using the below command, you get the error saying that Storage Replica has failed an application IO.

Get-WinEvent -ProviderName Microsoft-Windows-StorageReplica -max 20

In this case, the replication is not working and there are no other issues pointing to what could be the problem. In my case the solution was to restart the Storage Replica service from the services.msc. After this, I ran the Get-WinEvent command again and it was replicating again.