Is there a powershell way to achieve this? I have to do this for 40 servers.
Set the following permissions on all SharePoint servers in the farm (All must be done) – this is completed under Local Security Policy (gpedit.msc as administrator -> Windows Settings -> Security Settings -> Local Policies > User rights assignment) on each server
Grant Log on as a service
Impersonate a User
Act as part of the operating system
Best Answer
This solution worked perfectly.
https://gallery.technet.microsoft.com/scriptcenter/Grant-Revoke-Query-user-26e259b0