How to activate all inactive objects?

I want to be able to reset my level in the game I’m working on. To do this, I want to be able to find the inactive gameobjects and re-activate them. Is there any way I could do this? If it helps, the inactive gameobjects all share the same tag and a prefab as well.

Search for gameobjects and store them in an array. Then pass through that array and activate them.

public void activateObjects() {
        GameObject[] gameObjects = GameObject.FindGameObjectsWithTag("TAGNAME");
        foreach (GameObject go in gameObjects)
        {
            if (!go.activeInHierarchy)
            {
                go.SetActive(true);
            }
        }
    }