Exporting Objects to a CSV File
This topic explains how to use the Active Directory module for Windows PowerShell to export objects in Active Directory Domain Services (AD DS) to a comma-separated value (CSV) file.
Example
The following example demonstrates how to export the OU ManagedGroups and all its child objects to a CSV file:
Get-ADObject -Filter 'Name -like "*"' -Searchbase 'OU=ManagedGroups,DC=Fabrikam,DC=com' | Export-CSV ExportOU.csv
Get-ADObject -Filter 'Name -like "*"' -Searchbase 'OU=ManagedGroups,DC=Fabrikam,DC=com' | Export-CSV ExportOU.csv
Additional information
In addition to the standard Lightweight Directory Access Protocol (LDAP) attributes, you can retrieve the following extended properties of the Get-ADObject cmdlet by using the -Properties parameter:
- ObjectClass
- Created
- Modified
- Deleted
- ProtectedFromAccidentalDeletion
Importing Objects by Using a CSV File
This topic explains how to use the Active Directory module for Windows PowerShell to import objects from a comma-separated value (CSV) file into Active Directory Domain Services (AD DS).
Example
The following example demonstrates how to import the organizational unit (OU) ManagedGroups and all its child objects from a CSV file:
Import-CSV ImportOU.csv | foreach {New-ADObject -Path $_.Path -Name $_.Name -Type $_.Type}
Import-CSV ImportOU.csv | foreach {New-ADObject -Path $_.Path -Name $_.Name -Type $_.Type}
Additional information
The following parameters are the most commonly used parameters for creating Active Directory objects:
- -Description
- -DisplayName
- -ProtectedFromAccidentalDeletion
Referencing an External Domain
This topic explains how to use the Active Directory module for Windows PowerShell to refer to an external domain in Active Directory Domain Services (AD DS).
Example
The following example demonstrates how to create a cross-reference to the Northwind.com domain in the Fabrikam.com domain:
New-ADObject -Name northwind -Type crossref -OtherAttributes @{NcName="DC=NORTHWIND,DC=COM";DnsRoot="northwind-dc1.northwind.com"} -Path 'CN=Partitions,CN=Configuration,DC=FABRIKAM,DC=COM' -Description 'A cross reference to the external domain northwind.com'
New-ADObject -Name northwind -Type crossref -OtherAttributes @{NcName="DC=NORTHWIND,DC=COM";DnsRoot="northwind-dc1.northwind.com"} -Path 'CN=Partitions,CN=Configuration,DC=FABRIKAM,DC=COM' -Description 'A cross reference to the external domain northwind.com'
Additional information
The following property values are the most common values that are used in the creation of a new Active Directory object:
- Description
- DisplayName
- ProtectedFromAccidentalDeletion
No comments:
Post a Comment