A script that only works on one machine in one exact situation is still useful, but it becomes much more valuable when it can be reused in other places with minimal change. Reusability usually depends on a few simple design choices.
Reduce hard-coded assumptions
Paths, server names and fixed user-specific values are common reasons a script becomes difficult to reuse. Moving those into parameters or config variables helps immediately.
Use clear defaults when appropriate
Defaults can make scripts convenient without locking them into one environment. The key is to make those defaults easy to override.
Check dependencies visibly
If a script needs a module, a folder or elevated privileges, make that obvious. Reusable scripts should communicate what they need rather than silently failing in new environments.
Keep the purpose focused
Scripts are easier to reuse when they do one job well. Narrower purpose often leads to cleaner design and easier adaptation.
Reusability comes from reducing assumptions and making the script adaptable without forcing major rewrites every time it moves.