Ola Hallengren's SQL Server Maintenance Solution & CMD Syntax
How to automate SQL Server Express database maintenance using Windows Task Scheduler and Ola Hallengren’s maintenance solution has numerous examples of using SQLCMD to run Ola's scripts.
For example:
Database integrity check
sqlcmd -E -S .\SQLEXPRESS -d Tools -Q &quot;EXECUTE dbo.DatabaseIntegrityCheck @Databases = 'USER_DATABASES', @LogToTable = 'Y';&quot; -b -o D:\OLA\Logs\DatabaseIntegrityCheckUserDatabases.txt

Index optimize
sqlcmd -E -S .\SQLEXPRESS -d Tools -Q &quot;EXECUTE dbo.IndexOptimize @Databases = 'USER_DATABASES', @LogToTable = 'Y';&quot; -b -o D:\OLA\Logs\IndexOptimizeUserDatabases.txt