Hello, Loganathan. R,
one way is to use the slmgr.vbs script that comes on all Windows machines. Otherwise, WMI can accomplish this. Either approach should get the job done.
In order to use PowerShell remoting every target computer must have PowerShell installed and PowerShell remoting enabled and accessible. So first you should confirm this by running a simple command on each computer.
Invoke-Command -ComputerName SOMECOMPUTER -ScriptBlock {1}
If this returns 1, then it's working.
Once you have confirmed that PowerShell remoting is available on each computer, you will then need to figure out how to retrieve each computer name. if you have not done this already. If not, common ways include grabbing computer names from text files with Get-Content using the Path parameter when one computer exists on each line in a text file.
$computers = Get-Content -Path C:\computers.txt
Another common way to retrieve computer names is through the Get-ADComputer cmdlet available in the Active Directory module.
$computers = Get-ADComputer -Filter * | Select-Object -ExpandProperty Name
Regardless, you will simply need to build a collection of computer names somehow.
$computers = 'PC1','PC2','PC3', etc
After doing this, you will then need to figure out the syntax to invoke slmgr.vbs.
slmgr -ipk <ProductKeyHere>
Next, use Invoke-Command again and send this command to each computer all in one line.
Invoke-Command -ComputerName $computers -ScriptBlock { slmgr -ipk <ProductKeyHere> }
This will run on each computer and change the product key. If successful, a notification message for each computer will display.
--If the reply is helpful, please Upvote and Accept as answer--