# Add unit to reinstall

> Adds a unit to reinstall, optionally scheduling it and setting reinstall options.

Source: https://docs.capaone.com/capainstaller/sdk-capainstaller-software-development-kit-functions/unit-functions/add-unit-to-reinstall/  
Product: CapaInstaller — a separate CapaSystems product; do not apply this page to any other.

## Description

Adds unit to reinstall.

## Syntax

AddUnitToReinstall( Byval  ComputerName  as  String,  Byval  OSpointID  as  Integer,  Byval  OSserverID  as  Integer,  Byval  OSImageID  as  Integer,  Byval  DiskConfigID  as  Integer,  Byval  InstallTypeID  as  Integer, Optional  Byval  NewUnitName  as  String = "", Optional  Byval  ReinstallMode  as  String = "Silent", Optional  Byval  Active  as  Boolean = True,  Optional  Byval  UnlinkAllPackagesAndGroups  as  Boolean = False,  Optional  Byval  UnlinkAllAdvPackages  as  Boolean = False,  Optional  Byval  ChangelogComment  as  String = "")  as  Boolean

## Parameters

***ComputerName (String)***

The name or UUID of the computer

***OSpointID (Integer)***

The OS Point ID

***OSserverID (Integer)***

The OS Server ID

***OSImageID (Integer)***

OS Image ID

***DiskConfigID (Integer)***

The Disk Configuration ID

***InstallTypeID (Integer)***

The Install Type ID

***NewUnitName (String)***

The new name of the unit. This parameter is optional, and if omitted, the unit will keep the existing name

***ReinstallMode (String)***

The reinstall can be initialized in three ways;

- "Silent"
- "AlwaysConfirm"
- "ConfirmOnlyIfUserLoggedOn"

This parameter is optional. The default value is "Silent"

***Active (Boolean)***

Wether or not the computer should be active after the reinstall.

This parameter is optional. The default value is; True

***UnlinkAllPackagesAndGroups (Boolean)***

Wether or not all packages and groups should be unlinked

This parameter is optional. The default value is; False

***UnlinkAllAdvPackages (Boolean)***

Wether or not all advanced packages should be unlinked

This parameter is optional. The default value is; False

***ChangelogComment (String)***

The changelog comment for the change

This parameter is optional. The default value is; ""

***ReinstallStartDate (String)***

The reinstall start date in the format  "yyyy-MM-dd HH:mm" eg. "2015-04-15 12:05"

yyyy - Year with century.  
MM - Numeric month with a leading zero.  
dd - Numeric day of the month with a leading zero.  
HH - 24 Hour clock with leading zero.  
mm - Minutes with leading zero.

This parameter is optional. The default value is; "" which does not set a schedule for the reinstall but does it at next agent rerun.

***CustomField1 (String)***

The Value og CustomField1 in OS Deployment

This parameter is optional. The default value is; ""

***CustomField2 (String)***

The Value og CustomField2 in OS Deployment

This parameter is optional. The default value is; ""

## Return value

Boolean. The function returns True if successful, otherwise false.

## Example

**VBScript**

```vb
Set oCMS = CreateObject("CapaInstaller.SDK") 
wscript.echo oCMS.SetInstanceManagementPoint("1") 
wscript.echo oCMS.AddUnitToReinstall("Klient","1","1","3","2","1","KlientNew","AlwaysConfirm",True,False,False,"comment") 
```

With Schedule

**VBScript**

```vb
Set oCMS = CreateObject("CapaInstaller.SDK") 
wscript.echo oCMS.SetInstanceManagementPoint("1") 
wscript.echo oCMS.AddUnitToReinstall("Klient","1","1","3","2","1","KlientNew","AlwaysConfirm",True,False,False,"comment","2015-05-05 12:00") 
```

With CustomFields

**VBScript**

```vb
Set oCMS = CreateObject("CapaInstaller.SDK") 
wscript.echo oCMS.SetInstanceManagementPoint("1") 
wscript.echo oCMS.AddUnitToReinstall("Klient","1","1","3","2","1","KlientNew","AlwaysConfirm",True,False,False,"comment","", "CustomField1Value", "CustomField2Value") 
```

or if the unit has to keep the same name:

**VBScript**

```vb
 wscript.echo oCMS.AddUnitToReinstall("Klient","1","1","3","2","1") 
```
