Yes. They can also take your property away to search it, returning it months later.
The final decision of entry to a country(at that point) lies with the immigration officer. I imagine you can ask nicely for a review after you've been flown back to your point of origin.
I'll dig up some links, but seizure of non-citizen's computers at US borders is possible and scary. I treat the US border like a hackers conference - take a freshly imaged device, and refresh it on your return.