Magento 2 : How to run custom script on magento root?

Create a file on magento root and use object manager for using dependencies,

In below example you can see how we get product collection of a particular category using root script.

PHP

After creating the file run the script on browser or using cli

NOTE : This is not a best practice to build any feature in Magento, this is only for debugging purpose or one time code execution.