Possession and ownership are different questions
Owning a property does not always mean you can occupy it, and occupying it does not mean you own it. A tenant with a lease has a right to possession that limits the owner's. A family member or partner who was allowed to stay may be what the law calls a licensee, with fewer protections than a tenant but often still entitled to a court process before removal. New York has adjusted by statute how people who entered without any permission are treated, but how that plays out on the ground still varies, and many situations still end in court. The label that fits the occupant largely decides the route.
Why self-help usually backfires
Changing the locks, removing belongings, or cutting off utilities to force someone out of a home is unlawful in New York in most circumstances, and it can expose an owner to civil liability and, in some cases, criminal charges. Occupants who are locked out may be able to ask a court to restore them to possession. Police called to disputes with a former guest, relative, or partner often refer the matter to the courts, although someone who never had permission to enter may be treated differently. For commercial space, the lease and the circumstances matter more, but informal removal still carries risk.
Sorting out your situation
Gather whatever shows how the occupant came to be there: a lease, texts inviting them to stay, rent or utility payments, mail at the address, and the deed or closing documents. If you are the occupant, keep proof of what you have paid and of any agreement that you could stay. From those papers we work out what kind of occupant the law is likely to see, which court process applies, and whether an agreement on a move-out date or a buyout would get everyone there sooner.