Every now & then you run into a request where someone wants to know who all has access to a specific SharePoint site. All those who have fancy tools to work with don't have to worry about this, however some poor souls like me have to depend on PowerShell.
You can invoke the script by doing something like this.
$Users = Get-UsersInWeb -Url http://portal.contoso.com/sites/somesite
Once you have populated the variable $Users, you should be able to easily export it to CSV using a statement like the one below:
$Users | ConvertTo-Csv -NoTypeInformation | Out-File c:\users.csv