The sys.dm_db_page_info function was only introduced in SQL Server 2019.
Try to use the alternative sys.dm_db_database_page_allocations so that older SQL versions would be supported.
This means we won't have the used_bytes column, and we won't get visibility into the system pages, but maybe it's not too bad.