Approving SharePoint Master Pages Using PowerShell Commands

When I was editing my custom Master Page in the Share Point Designer 2013, I faced a problem in approving the master page through the User Interface. The best approach to avoid this kind of an issue is to run the powershell commands to approve the new Master Page.
 
$SPWeb = Get-SPWeb "http://localhost/mycustomSite"
$masterfile = $SPWeb.GetFile("_catalogs/masterpage/mymaster2013.master")
$masterfile .CheckIn("Approved")
$masterfile .Publish()