If you're running Windows 8 or later, there's a PowerShell cmdlet called Format-Volume. Otherwise, you can use good old format.com; it still works, even on Windows 8.
As for how you figure out which volume to format, we'd need more information there (and that's probably the "script" part of your question.) Once you know the letter, though, you can just do something like this:
$volume = 'f:' format $volume /Q /V:""