To retrieve the FSMO roles from the command line we can use dsquery command:
dsquery server –hasfsmo Schema (Schema Master)
dsquery server –hasfsmo Name (Domain Naming Master)
dsquery server –hasfsmo Infr (Infrastructure Master)
dsquery server –hasfsmo PDC (PDC Emulator)
dsquery server –hasfsmo RID (RID Master)