Randomly change power output on motor shield

I have a UNO R3 with a motor shield attached to it. I plan on powering everything with a 6v ac/dc inverter (think laptop charging cord with less voltage). I would like to vary power output on M1 (motor 1) from 2v to 6v at random intervals for random durations. I know I can use PWM and that 256 (I think that is the number) is equal to 100% or about 6v. I can lower this number to decrease the voltage.

Do you have a question?

yes.
How do I do what I described above?

On another project I used the below to make a dc motor turn at a set speed.
// Set the speed to start, from 0 (off) to 255 (max speed)
myMotor->setSpeed(145);
myMotor->run(FORWARD);
myMotor->run(RELEASE);

Hi @bc320,

You will need a MOSFET or other transistor attached to an Arduino PWM pin (PWM pins are shown on the board with ~ next to them).
PWM is 0 - 255.
You also might find this useful:
https://www.arduino.cc/reference/en/language/functions/random-numbers/random/

I have a mosfet motor shield (this one)
I found that link to random-numbers in my google search, but not sure how to incorporate it. I am sure that is what I need.

That motor shield does not utilize a MOSFET. It has a motor driver IC which is controlled via I2C. Here is a I2C library that might work for it:

Here is a tutorial on random():