The site is not valid. The ‘Pages’ document library is missing

When my colleague tries to create a page (Add a Page from Site Settings) in a SharePoint environment, he faces a strange error
"The site is not valid. The ‘Pages’ document library is missing".
 
To rectify this, we used the simple PowerShell commands, shown as follows.

$web = get-spweb "http://mysites/sites/ "

$correctId = $web.Lists["Pages"].ID

$web.AllProperties["__PagesListId"] = $correctId.ToString(

$web.Update()
 
What it does? It sets the Page ID again.
 
Happy Share Pointing :-)