Category: Uncategorized

  • How to: Add AzureAD/Entra ID user as local admin

    After joining a computer to AzureAD you will login with a user and will be automatically added as a local admin. The trouble is when logging with other users. These users will automatically set as users to the computer. From the Computer Management Console there is no way to add an AzureAD as when you click on Add and Locations, there is no location for the AzureAD. If you look at the current AAD user in the Computer Management and Local Users and Groups you will find the current user as AZUREAD\noel.pulis.

    Luckily there is a way to add an additional AzureAD user as a local admin.

    Open a command prompt window as the user and enter whomai.  This will give you the name of the domain along with the user, for example, mydomain\user.

    Open Command Prompt as Admin
    Type NET Localgroup Administrators <domain\user> /add

    Once this is ready, open the Local Users and Groups and you will find the AzureAD user part of the local Administrators Group.

  • How To: Automated shrink transaction logs in SQL

    Making a scheduled automated shrink logs for the databases with specific space to shrink.

    DECLARE @Step1 VARCHAR(200)
    DECLARE @Name varchar(50)

    DECLARE DBNames CURSOR
    FOR
    SELECT NAME FROM sysdatabases WHERE dbid > 4
    OPEN DBNames

    FETCH NEXT FROM DBNames INTO @Name WHILE (@@FETCH_STATUS <> -1)

    BEGIN

    SET @Step1 = 'USE ' + @Name + '' + CHAR(10)
    SET @Step1 = @Step1 + 'ALTER DATABASE [' + @Name + '] SET RECOVERY SIMPLE;' + CHAR(10)
    SET @Step1 = @Step1 + 'DBCC SHRINKFILE (' +@Name + '_LOG, 500);' + CHAR(10)
    SET @Step1 = @Step1 + 'ALTER DATABASE [' + @Name + '] SET RECOVERY FULL;' + CHAR(10)

    EXEC (@Step1)

    FETCH NEXT FROM DBNames INTO @Name
    END

    CLOSE DBNames
    DEALLOCATE DBNames