Artificial spin ices (ASI) have been widely investigated as magnetic metamaterials with exotic properties governed by their geometries. In parallel, interest in X-ray photon orbital angular momentum (OAM) has been rapidly growing. Here we show that a square ASI with a programmed topological defect, a double edge dislocation, imparts OAM to scattered X-rays. Unlike single dislocations, a double dislocation does not introduce magnetic frustration, and the ASI equilibrates to its antiferromagnetic (AF) ground state. The topological charge of the defect differs with respect to the structural and magnetic order; thus, X-ray diffraction from the ASI produces photons with even and odd OAM quantum numbers at the structural and AF Bragg conditions, respectively. The magnetic transitions of the ASI allow the AF OAM beams to be switched on and off by modest variations of temperature and applied magnetic field. These results demonstrate ASIs can serve as metasurfaces for reconfigurable X-ray optics that could enable selective probes of electronic and magnetic properties.