# Enable the local Administrator account

> A PowerPack example that enables the local Administrator account and sets its password.

Source: https://docs.capaone.com/capainstaller/powerpacks/powerpack-tips-and-examples/enable-the-local-administrator-account/  
Product: CapaInstaller — a separate CapaSystems product; do not apply this page to any other.

Enable local administrator account and set password:

**PowerShell**

```powershell
[CmdletBinding()]
Param(
  [Parameter(Mandatory=$true)]
  [string]$Packageroot,
  [Parameter(Mandatory=$true)]
  [string]$AppName,
  [Parameter(Mandatory=$true)]
  [string]$AppRelease,
  [Parameter(Mandatory=$true)]
  [string]$LogFile,
  [Parameter(Mandatory=$true)]
  [string]$TempFolder,
  [Parameter(Mandatory=$true)]
  [string]$DllPath,
  [Parameter(Mandatory=$false)]
  [Object]$InputObject=$null
)

try {
  $global:aeskey=@(177,185,19,134,62,241,80,22,70,244,23,168,237,185,210,199,58,255,173,93,250,159,101,244,247,44,211,43,100,217,96,38)
  $global:encpass='25892d1116743f0423413b16050a5345MgB8AGYAWgAwAGoAdAB1AHoANQBzAHUANgAwAHMAOQBWAEgAYgBSAG4AbwBsAFEAPQA9AHwAMAA2AGUAOQBjADkAZAAyAGYANQBkAGUAMAA3ADEAMgA0ADQAMAAzAGYAYQBjAGYAOAA5AGUAOQBjAGEAMQBmAGUANwA3AGQANABmADQAYQAwADQAZgA4ADcAYQA5AGMAMAAxADUANQAwAGMAYQA5ADkAZABhAGIAZAAzAGUANAA='

  ### Download package kit
  [bool]$global:DownloadPackage = $false

  ##############################################
  #load core PS lib - don't mess with this!
  if ($InputObject){$pgkit=""}else{$pgkit="kit"}
  Import-Module (Join-Path $Packageroot $pgkit "PSlib.psm1") -ErrorAction stop
  #load Library dll
  $cs=Add-PSDll
  ##############################################

  #Begin
  $cs.Job_Start("WS",$AppName,$AppRelease,$LogFile,"INSTALL")
  $cs.Job_WriteLog("[Init]: Starting package: '" + $AppName + "' Release: '" + $AppRelease + "'")
  if (!$cs.Sys_IsMinimumRequiredDiskspaceAvailable('c:', 1500)) {
    Exit-PSScript -exitcode 1 -exitmessage "Minimum required disk space not available"
  }
  if ($global:DownloadPackage -and $InputObject){Start-PSDownloadPackage}
  
  $cs.Job_WriteLog("[Init]: `$PackageRoot:` '" + $Packageroot + "'")
  $cs.Job_WriteLog("[Init]: `$AppName:` '" + $AppName + "'")
  $cs.Job_WriteLog("[Init]: `$AppRelease:` '" + $AppRelease + "'")
  $cs.Job_WriteLog("[Init]: `$LogFile:` '" + $LogFile + "'")
  $cs.Job_WriteLog("[Init]: `$TempFolder:` '" + $TempFolder + "'")
  $cs.Job_WriteLog("[Init]: `$DllPath:` '" + $DllPath + "'")
  $cs.Job_WriteLog("[Init]: `$global:DownloadPackage`: '" + $global:DownloadPackage + "'")
  

  $cs.Job_WriteLog("Enable local Administrator")
  Enable-LocalUser -Name 'Administrator' -ErrorAction:Ignore
  Set-LocalUser -Name 'Administrator' -Password ($global:encpass | ConvertTo-SecureString -key $global:aeskey) -AccountNeverExpires
  $cs.Job_WriteLog("Successfully enabled local Administrator")

  Exit-PSScript 0

}
catch {
  $line = $_.InvocationInfo.ScriptLineNumber
  $cs.Job_WriteLog("*****************","Something bad happend at line $($line): $($_.Exception.Message)")
  Exit-PSScript $_.Exception.HResult
}
```
