PowerShell Logo Small

Set-ADObject



This is the built-in help made by Microsoft for the command 'Set-ADObject', in PowerShell version 3 - as retrieved from Windows version 'Microsoft Windows Server 2012 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Modifies an Active Directory object.

SYNTAX


Set-ADObject [-Identity] <ADObject> [-Add <Hashtable>] [-AuthType <ADAuthType>] [-Clear <String[]>] [-Credential <PSCredential>] [-Description
<String>] [-DisplayName <String>] [-Partition <String>] [-PassThru [<SwitchParameter>]] [-ProtectedFromAccidentalDeletion <Boolean>] [-Remove
<Hashtable>] [-Replace <Hashtable>] [-Server <String>] [-Confirm [<SwitchParameter>]] [-WhatIf [<SwitchParameter>]] [<CommonParameters>]
Set-ADObject [-AuthType <ADAuthType>] [-Credential <PSCredential>] [-PassThru [<SwitchParameter>]] [-Server <String>] -Instance <ADObject>
[-Confirm [<SwitchParameter>]] [-WhatIf [<SwitchParameter>]] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Set-ADObject cmdlet modifies the properties of an Active Directory object. You can modify commonly used property values by using the
cmdlet parameters. Property values that are not associated with cmdlet parameters can be modified by using the Add, Replace, Clear and Remove
parameters.


The Identity parameter specifies the Active Directory object to modify. You can identify an object by its distinguished name (DN) or GUID. You
can also set the Identity parameter to an object variable such as $<localObject>, or you can pass an object through the pipeline to the
Identity parameter. For example, you can use the Get-ADObject cmdlet to retrieve an object and then pass the object through the pipeline to
the Set-ADObject cmdlet.


The Instance parameter provides a way to update an object by applying the changes made to a copy of the object. When you set the Instance
parameter to a copy of an Active Directory object that has been modified, the Set-ADObject cmdlet makes the same changes to the original
object. To get a copy of the object to modify, use the Get-ADObject object. The Identity parameter is not allowed when you use the Instance
parameter. For more information about the Instance parameter, see the Instance parameter description. For more information about how the
Instance concept is used in Active Directory cmdlets, see about_ActiveDirectory_Instance.


The following examples show how to modify the DisplayName property of an object by using three methods:


-By specifying the Identity and the DisplayName parameters


-By passing an object through the pipeline and specifying the DisplayName parameter


-By specifying the Instance parameter.


Method 1: Modify the DisplayName property for the SecurityLevel2AccessGroup object by using the Identity and DisplayName parameters.


Set-ADObject -Identity "SecurityLevel2AccessGroup" -DisplayName "Security Level 2"


Method 2: Modify the DisplayName property for the SecurityLevel2AccessGroup object by passing the SecurityLevel2AccessGroup object through the
pipeline and specifying the DisplayName parameter.


Get-ADObject -Identity "SecurityLevel2AccessGroup" | Set-ADObject -DisplayName "Security Level 2"


Method 3: Modify the DisplayName property for the SecurityLevel2AccessGroup object by using the Windows PowerShell command line to modify a
local instance of the SecurityLevel2AccessGroup object. Then set the Instance parameter to the local instance.


$adobject = Get-ADObject -Identity "SecurityLevel2AccessGroup"


$adobject.DisplayName = "Security Level 2"


Set-ADObject -Instance $adobject.


For AD LDS environments, the Partition parameter must be specified except in the following two conditions:


-The cmdlet is run from an Active Directory provider drive.


-A default naming context or partition is defined for the AD LDS environment. To specify a default naming context for an AD LDS environment,
set the msDS-defaultNamingContext property of the Active Directory directory service agent (DSA) object (nTDSDSA) for the AD LDS instance.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/?LinkID=219344
Get-ADObject
New-ADObject
Remove-ADObject

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

C:\PS>Set-ADObject 'CN=AntonioAl Direct Reports,OU=Finance,OU=UserAccounts,DC=FABRIKAM,DC=COM' -Description 'Distribution List of Antonio
Alwan Direct Reports'



Description

-----------

Set the Description property on the object with DistinguishedName 'CN=AntonioAl Direct Reports,OU=Finance,OU=UserAccounts,DC=FABRIKAM,DC=COM'.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>Set-ADObject 'CN=DEFAULTIPSITELINK,CN=IP,CN=Inter-Site Transports,CN=Sites,CN=Configuration,DC=FABRIKAM,DC=COM' -Add
@{siteList='CN=BO3,CN=Sites,CN=Configuration,DC=FABRIKAM,DC=COM'} -Partition 'CN=Configuration,DC=FABRIKAM,DC=COM'



Description

-----------

Add the site 'CN=BO3,CN=Sites,CN=Configuration,DC=FABRIKAM,DC=COM' to the property siteList on the object with DistinguishedName
'CN=DEFAULTIPSITELINK,CN=IP,CN=Inter-Site Transports,CN=Sites,CN=Configuration,DC=FABRIKAM,DC=COM'.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$urlValues = @()
$urlValues += "www.contoso.com"
$urlValues += "www.fabrikam.com"

Set-ADObject "cdadd380-d3a8-4fd1-9d30-5cf72d94a056" -Add @{url=$urlValues}



Description

-----------

Add two new urls to the property urlValues in the object with objectGuid 'cdadd380-d3a8-4fd1-9d30-5cf72d94a056'.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$urlValues = @()
$urlValues += "www.contoso.com"
$urlValues += "www.fabrikam.com"

Set-ADObject "cdadd380-d3a8-4fd1-9d30-5cf72d94a056" -Replace @{url=$urlValues;description="Antonio Alwan"}



Description

-----------

Replaces the old values of the multi-valued attribute 'url' with the new values and sets the value of the attribute 'description'.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>Set-ADObject "cdadd380-d3a8-4fd1-9d30-5cf72d94a056" -Remove @{url="www.contoso.com"} -Replace @{description="Antonio Alwan (European
Manager)"}



Description

-----------

Removes the specified value from the attribute 'url' and sets the value of the attribute 'description'.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>$myComp = Get-ADObject -identity "cdadd380-d3a8-4fd1-9d30-5cf72d94a056" -Properties "userAccountControl","description"

#Now set the new account control using powershell bitwise OR operation (-bor) and set description
$myComp.userAccountControl = $myComp.userAccountControl -bor 50
$myComp.description = "Setting a new UAC on the object"

#Save the changes
Set-ADObject -Instance $myComp



Description

-----------

Sets a new UAC bit on an object by updating the attribute 'userAccountControl' and setting the value of the attribute 'description'.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>set-adobject "CN=InternalApps,DC=AppNC" -protectedFromAccidentalDeletion $true -server "FABRIKAM-SRV1:60000"



Description

-----------

Sets container "CN=InternalApps,DC=AppNC" in an LDS instance to be protected from accidental deletion