Hi,
This maybe OS dependant and its relating to -RepetitionDuration. I believe on Win10/Server 2016+ to create it to run indefinitely you omit the -RepetitionDuration and only need to add in the interval
$action = New-ScheduledTaskAction -Execute "pwsh.exe" -Argument "-NonInteractive -NoLogo -NoProfile -File 'C:\Users\Nia\Desktop\Brute-force-ctf\hint.txt'"
$trigger = New-ScheduledTaskTrigger -Once -At 11pm -RepetitionInterval (New-TimeSpan -Days 1)
$settings = New-ScheduledTaskSettingsSet
Register-ScheduledTask -Action $action -Trigger $trigger -Settings $settings -TaskName "test" -Description "This is a test"
You don't mention where your using the script so it maybe you need to put OS checks in place depending on if its a Server 2016 or newer / Win 10 system.