$key = Get-WmiObject -Query "select oa3xoriginalproductkey from softwarelicensingservice" slmgr /ipk $key.oa3xoriginalproductkey this is jus an example: Powershell.exe -ExecutionPolicy Unrestricted -File c:\data\test.ps1