Can you be more clear about "doesn't work?" Is there an error? Have you tried running that same code locally against just a single computer? My guess is either permissions or something in the syntax of your command. Or, the remote machines don't have Invoke-SQLCmd2 available.