The newest polarization controllers, like the N7785C have a convenient SCPI command set for programming. The functions to generate a sequence of polarization states that can be repeatedly scanned and synchronized with other instruments is very powerful. This application note describes an application for measuring PDL or PER with a rapid all-states method.
All-States Method for PDL or PER Synchronous Polarization Scrambler (keysight.com)
An example program as python script is attached here.
This example also adds some steps to set the polarization to the states of the sequence that give highest and lowest signal. This is a valuable function for example to align with a polarizing component like a grating coupler on a photonic integrated circuit (PIC). As explained in the note, for measuring on a device with high polarization extinction, the random-walk sequence with many fast samples is a good configuration.