As per my understanding you want get all art boards and dosomething
i just implemented for each artboard only so you can extend it furthur
this is my crazy implementation
function myPluginCommand(selection, documentRoot) {
var rootnodes = selection.insertionParent.parent;
var nodes = selection.items[0];
console.log(rootnodes);
rootnodes.children.forEach(element => {
console.log(element.name);
selection.items = [element];
let rect = new Rectangle();
rect.height = 100;
rect.width = 100;
rect.fill = new Color("grey");
selection.insertionParent.addChild(rect);
});
}