

$Executable = $env:windir + "\System32\cscript.exe" Write-Host "Activate Microsoft Office." -NoNewline $WindowsProductKey,įunction Get-OfficeSoftwareProtectionPlatform $ConsoleTitle = 'Microsoft Office and Windows Activation', NOTE: I advise putting the script near the end of a task sequence. Here is a screenshot of the script in action: powershell.exe -executionpolicy bypass -command ActivateOfficeWindows.ps1 -ActiveOffice.powershell.exe -executionpolicy bypass -command ActivateOfficeWindows.ps1 -OfficeProductKey "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX".Input the office product key without activation.powershell.exe -executionpolicy bypass -command ActivateOfficeWindows.ps1 -OfficeProductKey "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" -ActiveOffice.Input the office product key and activate office.powershell.exe -executionpolicy bypass -command ActivateOfficeWindows.ps1 -ActivateWindows.powershell.exe -executionpolicy bypass -command ActivateOfficeWindows.ps1 -WindowsProductKey "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX".

Input the windows product key without activation.powershell.exe -executionpolicy bypass -command ActivateOfficeWindows.ps1 -WindowsProductKey "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" -ActivateWindows.Input the windows product key and activate windows.powershell.exe -executionpolicy bypass -command ActivateOfficeWindows.ps1 -OfficeProductKey "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" -WindowsProductKey "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" -ActiveOffice -ActivateWindows.Input the product keys and activate both office and windows.I used SAPIEN's PowerShell Studio to write this script and I can attest that it made writing it a breeze! Here are some examples below of running the script at the command prompt:


I also wrote this script so that if any of the functions fail, it will return an error code 1 so the build will report an error in this task sequence. I have used the script on Windows 7, Windows 10, Office 2010, and Office 2016. If you wanted to hard code the keys, that can be done at the parameter fields. I setup the script so the product keys can be entered at the command line prompt to protect the exposure of the key when used in MDT or SCCM. This script will allow you to enter a product key and/or activate the product. If an imaging process fails, I don't want a MAK activation wasted. I also chose to write this script so that I did not have to enter the product keys and activation in the image. I wrote this script because we currently have both x86 and 圆4 systems, therefore the OSPP.vbs resides in different locations. Here is a script that will activate both Microsoft Office and Microsoft Windows.
