The agricultural machine has an attachment device (2) for attaching different attachments (3) for harvest- and soil treatment, a soil detecting unit (11) for contactless detection of a soil- or harvest contour and a control device (12) for controlling the agricultural machine and the attachments depending on the detected soil- or harvest contour. The soil detecting unit detects a laser measuring device (13), whose laser beam (14) is guided for scanning the soil- or harvest contour over a scanning area (15).