- 1 year ago
Does anyone knows how to use the slmgr /ipk using PS AppDeployToolkit?
To use the slmgr /ipk
command with the PowerShell App Deployment Toolkit (PSADT), you can leverage the Execute-Process
function provided by the toolkit. Here's an example of how you can use it:
powershell# Import the PSADT module
Import-Module .\AppDeployToolkit\AppDeployToolkitMain.ps1
# Define the product key
$productKey = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"
# Define the slmgr command with the product key
$slmgrCommand = "slmgr /ipk $productKey"
# Execute the slmgr command using the Execute-Process function from PSADT
Execute-Process -Path "slmgr.exe" -Parameters "/ipk $productKey" -WindowStyle Hidden -IgnoreExitCodes @() -ContinueOnError $false
# Rest of your deployment script...
# Perform any other necessary tasks using PSADT functions
# Exit the script
Exit-Script
In this example, the Execute-Process
function is used to run the slmgr.exe
command with the /ipk
parameter and the provided product key. The function allows you to customize parameters such as the window style, exit code handling, and error handling.
Make sure to replace "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"
with your actual product key. Adjust any other parameters or options as needed for your deployment script.
Remember to have the PSADT files, such as AppDeployToolkitMain.ps1
, available in the same directory as your deployment script or update the path accordingly.
By utilizing the Execute-Process
function from the PowerShell App Deployment Toolkit, you can incorporate the slmgr /ipk
command seamlessly into your deployment script.