This command allows you to change the command state of your targeted NPC. A command state of 1 allows you to control an NPC in a similar way to that of a companion, even if they are outside of your settlement.
setcommandstate [command state] Target Command
|Command State||The command state to set the targeted NPC to. 0 to set them to default command state. Entering 1 here will allow them to be controlled in a similar way to companions even if they are outside of your settlement.|
The above command sets the command state of the NPC with reference ID ff0044532 to 1.