Defend (feral ghouls)

Defend (displayed as Defend (Location Name)) is a Minutemen radiant quest $$

Detailed walkthrough
This quest can be periodically obtained when entering an owned settlement at night. The leader of the settlement will inform the Sole Survivor of a nearby group of ghouls about to attack the settlement under cover of darkness.

To complete the objective, the Sole Survivor must use the settlement workshop to build defensive buildings until the settlement has a defense rating of at least 10 (the Pip-Boy will indicate the percentage toward this goal as they build). After reaching the required rating a group of feral ghouls will spawn and begin attacking the settlement. The Sole Survivor can help eliminate the attackers or let the settlement's defenses handle it. Either way, if the settlement takes too much damage or the leader of the settlement is killed, the quest will fail.

With the threat neutralized, the Sole Survivor can talk to the settler from before to receive thanks and a reward of ~100 caps.

Bugs
In certain locations, NPCs might spawn in inaccessible locations (for instance, Roger Warwick at Warwick homestead might spawn inside the water cistern). This bug is shared with the other settlement quests.
 * This can be resolved by using the console command to teleport the NPC in question.
 * The Warwick homestead example can be resolved by building stairs into the cistern and a bell outside of it. Using the bell and waiting for an in-game hour (using the Wait option) will cause the NPCs to spawn near the bell.