ADDS PowerShell (CMDLET, ADSI & .Net) to Expedite Your Tasks
CMDLET
1. How to get the DFL?
PS C:\> Get-ADDomain | findstr / 'DomainMode'
{Quoted text is case sensitive)
2. How to get the FFL?
PS C:\> Get-ADForest | findstr / 'ForestMode'
(Quoted text is case sensitive)
3. How to get the ADDefaultDomainPasswordPolicy?
PS C:\> Get-ADDefaultDomainPasswordPolicy
4. How to get the all Trusts information.
PS C:\> Get-ADTrust -f * | ft
5. Find some specific attributes for an OU users.
PS C:\> get-aduser -f * -Searchbase "ou=powershell,dc=contoso,dc=com" -pr SamAccountName,PasswordExpired,whenChanged,UserPrincipalName
6. Generate a report for all AD users samaccountname,LastLogonDate,Enabled
PS C:\> get-aduser -f * -pr lastlogondate | ft samaccountname,LastLogonDate,Enabled -auto
See the below snap.
7. Getting DFL & FFL using "Get-ADRootDSE"; see the below snap.
**Two lines that can save your AD from a crisis------Prevent accidental deletions of AD objects
**
http://blogs.technet.com/b/askds/archive/2013/06/04/two-lines-that-can-save-your-ad-from-a-crisis.aspx
For All users
8.Get-ADObject -filter {(ObjectClass -eq "user")} | Set-ADObject -ProtectedFromAccidentalDeletion:$true
For All OUs
9.Get-ADOrganizationalUnit -filter * | Set-ADObject -ProtectedFromAccidentalDeletion:$true
For All Groups
10. Get-ADObject -filter {ObjectClass -eq "user" -or ObjectClass -eq "group"} | Set-ADObject -ProtectedFromAccidentalDeletion:$true
11.Reset the password for all users of an OU
PS C:\> Get-ADUser -Filter * -SearchBase "ou=test,dc=biz,dc=net"| Set-ADAccountPassword -NewPassword (ConvertTo-SecureString -AsPlainText monster@me123 -Force)
12.Finding Global Catalog
Get-ADForest biz.net | FL GlobalCatalogs
13. Finding last 20 events from Directory Service.
get-eventlog 'Directory Service' -newest 20 | Format-List indx, source, message
14. Find event log entries with a specific text.
Get -EventLog System | Where- Object { $_.Message -match "disk" }
15. How to get the FSMO?
Get-ADDomain | select PDCEmulator,RIDMaster,InfrastructureMaster | fl
Get-ADForest | select DomainNamingMaster, SchemaMaster | fl
PowerShell Function to Determine the Active Directory FSMO Role Holders
http://gallery.technet.microsoft.com/scriptcenter/PowerShell-Function-to-bec6c607- Written by Mike F Robbins
- Reboot Report
Get -EventLog -ComputerName <computer_name> System | Where- Object { $_.Source -eq 'user32' } | ConvertTo-HTML | Out-File C:\Reboot.htm
Get-EventLog System | ? Source -eq user32 | select TimeGenerated,UserName -First 1
17.How to unlock the AD accounts.
Search-ADAccount –LockedOut | Unlock-ADAccount
18. How to find the commands are available in a particular Module.
Get-Command -Module dnsserver
19. DCs Inventory -> Output in a CSV
Get-ADDomainController -Filter * | select name, operatingsystem,HostName,site,IsGlobalCatalog,IsReadOnly | Export-Csv c:\dcinventory.csv
20. How to find the Roles those are installed.
.
Microsoft released PowerShell version 2 & 3 and now version 4 has been released with Windows 8.1 & Server 2012 R2. Now it is very difficult to remember the each cmdlet. Built-in cmdlet mean dependency come into the picture. In that case managing the Active Directory with day by day work can be a difficult task but we have a solution and without dependency. Where we have legacy OS like 2008 mean built-in CMDLET is not present there.
We might don't have 2008 R2 where AD module is present in each DC. Now, how can we work with 2008(Non R2) where AD module is not present? Answer is simple using PowerShell ADSI. See the below example.
ADSI
PowerShell ADSI(Active Directory Services Interface) commands
1. How to find the users property.
$users1=[ADSI]"LDAP://cn=copy,cn=users,dc=contoso,dc=com"
$users1 | select *
2. How to find the Group members for a Group.
$test = [ADSI]"LDAP://CN=test,CN=Users,DC=contoso,DC=com"
$test.Member | ForEach-Object {[ADSI]"LDAP://$_"} | select samccountname, samaccounttype
3. Listing an OU Contents
PS C:\ $ou=[ADSI]"LDAP://ou=tech,dc=contoso,dc=com"
PS C:\ $ou.PSBase.Children
PS C:\ $ou.PSBase.Children | Format-Table sAMAccountName
4. Finding FSMO using .Net Namespace "System.DirectoryServices"
PS C:\ [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain() | Select-Object *owner
PS C:\ [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() | Select-Object *owner
5. Finding All attributes & Properties
PS C:\ $Domain=[ADSI]""
PS C:\ $Domain
distinguishedName : {DC=msft,DC=net}
Path :
PS C:\ $Domain | select *
objectClass : {top, domain, domainDNS}
distinguishedName : {DC=msft,DC=net}
instanceType : {5}
whenCreated : {9/8/2013 5:50:00 AM}
whenChanged : {9/8/2013 5:54:14 AM}
subRefs : {DC=ForestDnsZones,DC=msft,DC=net, DC=DomainDnsZones,DC=msft,DC=net,
CN=Configuration,DC=msft,DC=net}
uSNCreated : {System.__ComObject}
uSNChanged : {System.__ComObject}
name : {msft}
objectGUID : {96 102 174 230 125 103 254 72 172 113 42 246 125 188 76 89}
creationTime : {System.__ComObject}
forceLogoff : {System.__ComObject}
lockoutDuration : {System.__ComObject}
lockOutObservationWindow : {System.__ComObject}
lockoutThreshold : {0}
maxPwdAge : {System.__ComObject}
minPwdAge : {System.__ComObject}
minPwdLength : {7}
modifiedCountAtLastProm : {System.__ComObject}
nextRid : {1002}
pwdProperties : {1}
pwdHistoryLength : {24}
objectSid : {1 4 0 0 0 0 0 5 21 0 0 0 31 75 17 20 205 108 73 130 55 176 64 85}
serverState : {1}
uASCompat : {1}
modifiedCount : {System.__ComObject}
auditingPolicy : {0 1}
nTMixedDomain : {0}
rIDManagerReference : {CN=RID Manager$,CN=System,DC=msft,DC=net}
fSMORoleOwner : {CN=NTDS Settings,CN=WIN-TBPDE99QC8I,CN=Servers,CN=Default-First-Site-Name,CN=Sites,
CN=Configuration,DC=msft,DC=net}
systemFlags : {-1946157056}
wellKnownObjects : {System.__ComObject, System.__ComObject, System.__ComObject, System.__ComObject...}
objectCategory : {CN=Domain-DNS,CN=Schema,CN=Configuration,DC=msft,DC=net}
isCriticalSystemObject : {True}
gPLink : {[LDAP://CN={31B2F340-016D-11D2-945F-00C04FB984F9},CN=Policies,CN=System,DC=msft,DC=
net;0]}
dSCorePropagationData : {1/1/1601 12:00:00 AM}
otherWellKnownObjects : {System.__ComObject}
masteredBy : {CN=NTDS Settings,CN=WIN-TBPDE99QC8I,CN=Servers,CN=Default-First-Site-Name,CN=Sites,
CN=Configuration,DC=msft,DC=net}
ms-DS-MachineAccountQuota : {10}
msDS-Behavior-Version : {2}
msDS-PerUserTrustQuota : {1}
msDS-AllUsersTrustQuota : {1000}
msDS-PerUserTrustTombstonesQuota : {10}
msDs-masteredBy : {CN=NTDS Settings,CN=WIN-TBPDE99QC8I,CN=Servers,CN=Default-First-Site-Name,CN=Sites,
CN=Configuration,DC=msft,DC=net}
msDS-IsDomainFor : {CN=NTDS Settings,CN=WIN-TBPDE99QC8I,CN=Servers,CN=Default-First-Site-Name,CN=Sites,
CN=Configuration,DC=msft,DC=net}
msDS-NcType : {0}
dc : {msft}
nTSecurityDescriptor : {System.__ComObject}
AuthenticationType : Secure
Children : {Builtin, Computers, Domain Controllers, ForeignSecurityPrincipals...}
Guid : 6066aee67d67fe48ac712af67dbc4c59
ObjectSecurity : System.DirectoryServices.ActiveDirectorySecurity
NativeGuid : 6066aee67d67fe48ac712af67dbc4c59
NativeObject : System.__ComObject
Parent : LDAP://DC=net
Password :
Path :
Properties : {objectClass, distinguishedName, instanceType, whenCreated...}
SchemaClassName : domainDNS
SchemaEntry : System.DirectoryServices.DirectoryEntry
UsePropertyCache : True
Username :
Options : {}
Site :
Container :
How to get the Property & Method
PS C:\ $Domain | gm -MemberType Property
TypeName: System.DirectoryServices.DirectoryEntry
Name MemberType Definition
---- ---------- ----------
auditingPolicy Property System.DirectoryServices.PropertyValueCollection auditingPolicy {get;set;}
creationTime Property System.DirectoryServices.PropertyValueCollection creationTime {get;set;}
dc Property System.DirectoryServices.PropertyValueCollection dc {get;set;}
distinguishedName Property System.DirectoryServices.PropertyValueCollection distinguishedName {get;...
dSCorePropagationData Property System.DirectoryServices.PropertyValueCollection dSCorePropagationData {...
forceLogoff Property System.DirectoryServices.PropertyValueCollection forceLogoff {get;set;}
fSMORoleOwner Property System.DirectoryServices.PropertyValueCollection fSMORoleOwner {get;set;}
gPLink Property System.DirectoryServices.PropertyValueCollection gPLink {get;set;}
instanceType Property System.DirectoryServices.PropertyValueCollection instanceType {get;set;}
isCriticalSystemObject Property System.DirectoryServices.PropertyValueCollection isCriticalSystemObject ...
lockoutDuration Property System.DirectoryServices.PropertyValueCollection lockoutDuration {get;set;}
lockOutObservationWindow Property System.DirectoryServices.PropertyValueCollection lockOutObservationWindo...
lockoutThreshold Property System.DirectoryServices.PropertyValueCollection lockoutThreshold {get;s...
masteredBy Property System.DirectoryServices.PropertyValueCollection masteredBy {get;set;}
maxPwdAge Property System.DirectoryServices.PropertyValueCollection maxPwdAge {get;set;}
minPwdAge Property System.DirectoryServices.PropertyValueCollection minPwdAge {get;set;}
minPwdLength Property System.DirectoryServices.PropertyValueCollection minPwdLength {get;set;}
modifiedCount Property System.DirectoryServices.PropertyValueCollection modifiedCount {get;set;}
modifiedCountAtLastProm Property System.DirectoryServices.PropertyValueCollection modifiedCountAtLastProm...
ms-DS-MachineAccountQuota Property System.DirectoryServices.PropertyValueCollection ms-DS-MachineAccountQuo...
msDS-AllUsersTrustQuota Property System.DirectoryServices.PropertyValueCollection msDS-AllUsersTrustQuota...
msDS-Behavior-Version Property System.DirectoryServices.PropertyValueCollection msDS-Behavior-Version {...
msDS-IsDomainFor Property System.DirectoryServices.PropertyValueCollection msDS-IsDomainFor {get;s...
msDs-masteredBy Property System.DirectoryServices.PropertyValueCollection msDs-masteredBy {get;set;}
msDS-NcType Property System.DirectoryServices.PropertyValueCollection msDS-NcType {get;set;}
msDS-PerUserTrustQuota Property System.DirectoryServices.PropertyValueCollection msDS-PerUserTrustQuota ...
msDS-PerUserTrustTombstonesQuota Property System.DirectoryServices.PropertyValueCollection msDS-PerUserTrustTombst...
name Property System.DirectoryServices.PropertyValueCollection name {get;set;}
nextRid Property System.DirectoryServices.PropertyValueCollection nextRid {get;set;}
nTMixedDomain Property System.DirectoryServices.PropertyValueCollection nTMixedDomain {get;set;}
nTSecurityDescriptor Property System.DirectoryServices.PropertyValueCollection nTSecurityDescriptor {g...
objectCategory Property System.DirectoryServices.PropertyValueCollection objectCategory {get;set;}
objectClass Property System.DirectoryServices.PropertyValueCollection objectClass {get;set;}
objectGUID Property System.DirectoryServices.PropertyValueCollection objectGUID {get;set;}
objectSid Property System.DirectoryServices.PropertyValueCollection objectSid {get;set;}
otherWellKnownObjects Property System.DirectoryServices.PropertyValueCollection otherWellKnownObjects {...
pwdHistoryLength Property System.DirectoryServices.PropertyValueCollection pwdHistoryLength {get;s...
pwdProperties Property System.DirectoryServices.PropertyValueCollection pwdProperties {get;set;}
rIDManagerReference Property System.DirectoryServices.PropertyValueCollection rIDManagerReference {ge...
serverState Property System.DirectoryServices.PropertyValueCollection serverState {get;set;}
subRefs Property System.DirectoryServices.PropertyValueCollection subRefs {get;set;}
systemFlags Property System.DirectoryServices.PropertyValueCollection systemFlags {get;set;}
uASCompat Property System.DirectoryServices.PropertyValueCollection uASCompat {get;set;}
uSNChanged Property System.DirectoryServices.PropertyValueCollection uSNChanged {get;set;}
uSNCreated Property System.DirectoryServices.PropertyValueCollection uSNCreated {get;set;}
wellKnownObjects Property System.DirectoryServices.PropertyValueCollection wellKnownObjects {get;s...
whenChanged Property System.DirectoryServices.PropertyValueCollection whenChanged {get;set;}
whenCreated Property System.DirectoryServices.PropertyValueCollection whenCreated {get;set;}
PS C:\ [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
Forest : msft.net
DomainControllers : {WIN-0KKDGE8VSS3.msft.net, WIN-TBPDE99QC8I.msft.net}
Children : {}
DomainMode : Windows2003Domain
Parent :
PdcRoleOwner : WIN-TBPDE99QC8I.msft.net
RidRoleOwner : WIN-TBPDE99QC8I.msft.net
InfrastructureRoleOwner : WIN-TBPDE99QC8I.msft.net
Name : msft.net
PS C:\ [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
Name : msft.net
Sites : {Default-First-Site-Name}
Domains : {msft.net}
GlobalCatalogs : {WIN-0KKDGE8VSS3.msft.net, WIN-TBPDE99QC8I.msft.net}
ApplicationPartitions : {DC=ForestDnsZones,DC=msft,DC=net, DC=DomainDnsZones,DC=msft,DC=net}
ForestMode : Windows2003Forest
RootDomain : msft.net
Schema : CN=Schema,CN=Configuration,DC=msft,DC=net
SchemaRoleOwner : WIN-TBPDE99QC8I.msft.net
NamingRoleOwner : WIN-TBPDE99QC8I.msft.net
PS C:\ [System.DirectoryServices.ActiveDirectory.Domain] | gm -MemberType Method
TypeName: System.RuntimeType
Name MemberType Definition
---- ---------- ----------
AsType Method type AsType()
Clone Method System.Object Clone(), System.Object ICloneable.Clone()
Equals Method bool Equals(System.Object obj), bool Equals(type o), bool _MemberInfo.Equa...
FindInterfaces Method type[] FindInterfaces(System.Reflection.TypeFilter filter, System.Object f...
FindMembers Method System.Reflection.MemberInfo[] FindMembers(System.Reflection.MemberTypes m...
GetArrayRank Method int GetArrayRank(), int _Type.GetArrayRank()
GetConstructor Method System.Reflection.ConstructorInfo GetConstructor(System.Reflection.Binding...
GetConstructors Method System.Reflection.ConstructorInfo[] GetConstructors(System.Reflection.Bind...
GetCustomAttributes Method System.Object[] GetCustomAttributes(bool inherit), System.Object[] GetCust...
GetCustomAttributesData Method System.Collections.Generic.IList[System.Reflection.CustomAttributeData] Ge...
GetDeclaredEvent Method System.Reflection.EventInfo GetDeclaredEvent(string name)
GetDeclaredField Method System.Reflection.FieldInfo GetDeclaredField(string name)
GetDeclaredMethod Method System.Reflection.MethodInfo GetDeclaredMethod(string name)
GetDeclaredMethods Method System.Collections.Generic.IEnumerable[System.Reflection.MethodInfo] GetDe...
GetDeclaredNestedType Method System.Reflection.TypeInfo GetDeclaredNestedType(string name)
GetDeclaredProperty Method System.Reflection.PropertyInfo GetDeclaredProperty(string name)
GetDefaultMembers Method System.Reflection.MemberInfo[] GetDefaultMembers(), System.Reflection.Memb...
GetElementType Method type GetElementType(), type _Type.GetElementType()
GetEnumName Method string GetEnumName(System.Object value)
GetEnumNames Method string[] GetEnumNames()
GetEnumUnderlyingType Method type GetEnumUnderlyingType()
GetEnumValues Method array GetEnumValues()
GetEvent Method System.Reflection.EventInfo GetEvent(string name, System.Reflection.Bindin...
GetEvents Method System.Reflection.EventInfo[] GetEvents(System.Reflection.BindingFlags bin...
GetField Method System.Reflection.FieldInfo GetField(string name, System.Reflection.Bindin...
GetFields Method System.Reflection.FieldInfo[] GetFields(System.Reflection.BindingFlags bin...
GetGenericArguments Method type[] GetGenericArguments()
GetGenericParameterConstraints Method type[] GetGenericParameterConstraints()
GetGenericTypeDefinition Method type GetGenericTypeDefinition()
GetHashCode Method int GetHashCode(), int _MemberInfo.GetHashCode(), int _Type.GetHashCode()
GetIDsOfNames Method void _MemberInfo.GetIDsOfNames([ref] guid riid, System.IntPtr rgszNames, u...
GetInterface Method type GetInterface(string fullname, bool ignoreCase), type GetInterface(str...
GetInterfaceMap Method System.Reflection.InterfaceMapping GetInterfaceMap(type ifaceType), System...
GetInterfaces Method type[] GetInterfaces(), type[] _Type.GetInterfaces()
GetMember Method System.Reflection.MemberInfo[] GetMember(string name, System.Reflection.Me...
GetMembers Method System.Reflection.MemberInfo[] GetMembers(System.Reflection.BindingFlags b...
GetMethod Method System.Reflection.MethodInfo GetMethod(string name, System.Reflection.Bind...
GetMethods Method System.Reflection.MethodInfo[] GetMethods(System.Reflection.BindingFlags b...
GetNestedType Method type GetNestedType(string fullname, System.Reflection.BindingFlags binding...
GetNestedTypes Method type[] GetNestedTypes(System.Reflection.BindingFlags bindingAttr), type[] ...
GetObjectData Method void GetObjectData(System.Runtime.Serialization.SerializationInfo info, Sy...
GetProperties Method System.Reflection.PropertyInfo[] GetProperties(System.Reflection.BindingFl...
GetProperty Method System.Reflection.PropertyInfo GetProperty(string name, System.Reflection....
GetType Method type GetType(), type _MemberInfo.GetType(), type _Type.GetType()
GetTypeInfo Method void _MemberInfo.GetTypeInfo(uint32 iTInfo, uint32 lcid, System.IntPtr ppT...
GetTypeInfoCount Method void _MemberInfo.GetTypeInfoCount([ref] uint32 pcTInfo), void _Type.GetTyp...
Invoke Method void _MemberInfo.Invoke(uint32 dispIdMember, [ref] guid riid, uint32 lcid,...
InvokeMember Method System.Object InvokeMember(string name, System.Reflection.BindingFlags bin...
IsAssignableFrom Method bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo), bool IsAssigna...
IsDefined Method bool IsDefined(type attributeType, bool inherit), bool ICustomAttributePro...
IsEnumDefined Method bool IsEnumDefined(System.Object value)
IsEquivalentTo Method bool IsEquivalentTo(type other)
IsInstanceOfType Method bool IsInstanceOfType(System.Object o), bool _Type.IsInstanceOfType(System...
IsSubclassOf Method bool IsSubclassOf(type type), bool _Type.IsSubclassOf(type c)
MakeArrayType Method type MakeArrayType(), type MakeArrayType(int rank)
MakeByRefType Method type MakeByRefType()
MakeGenericType Method type MakeGenericType(Params type[] instantiation)
MakePointerType Method type MakePointerType()
ToString Method string ToString(), string _MemberInfo.ToString(), string _Type.ToString()
PS C:\ [System.DirectoryServices.ActiveDirectory.Domain] | gm -MemberType Property
TypeName: System.RuntimeType
Name MemberType Definition
---- ---------- ----------
Assembly Property System.Reflection.Assembly Assembly {get;}
AssemblyQualifiedName Property string AssemblyQualifiedName {get;}
Attributes Property System.Reflection.TypeAttributes Attributes {get;}
BaseType Property type BaseType {get;}
ContainsGenericParameters Property bool ContainsGenericParameters {get;}
CustomAttributes Property System.Collections.Generic.IEnumerable[System.Reflection.CustomAttributeData] ...
DeclaredConstructors Property System.Collections.Generic.IEnumerable[System.Reflection.ConstructorInfo] Decl...
DeclaredEvents Property System.Collections.Generic.IEnumerable[System.Reflection.EventInfo] DeclaredEv...
DeclaredFields Property System.Collections.Generic.IEnumerable[System.Reflection.FieldInfo] DeclaredFi...
DeclaredMembers Property System.Collections.Generic.IEnumerable[System.Reflection.MemberInfo] DeclaredM...
DeclaredMethods Property System.Collections.Generic.IEnumerable[System.Reflection.MethodInfo] DeclaredM...
DeclaredNestedTypes Property System.Collections.Generic.IEnumerable[System.Reflection.TypeInfo] DeclaredNes...
DeclaredProperties Property System.Collections.Generic.IEnumerable[System.Reflection.PropertyInfo] Declare...
DeclaringMethod Property System.Reflection.MethodBase DeclaringMethod {get;}
DeclaringType Property type DeclaringType {get;}
FullName Property string FullName {get;}
GenericParameterAttributes Property System.Reflection.GenericParameterAttributes GenericParameterAttributes {get;}
GenericParameterPosition Property int GenericParameterPosition {get;}
GenericTypeArguments Property type[] GenericTypeArguments {get;}
GenericTypeParameters Property type[] GenericTypeParameters {get;}
GUID Property guid GUID {get;}
HasElementType Property bool HasElementType {get;}
ImplementedInterfaces Property System.Collections.Generic.IEnumerable[type] ImplementedInterfaces {get;}
IsAbstract Property bool IsAbstract {get;}
IsAnsiClass Property bool IsAnsiClass {get;}
IsArray Property bool IsArray {get;}
IsAutoClass Property bool IsAutoClass {get;}
IsAutoLayout Property bool IsAutoLayout {get;}
IsByRef Property bool IsByRef {get;}
IsClass Property bool IsClass {get;}
IsCOMObject Property bool IsCOMObject {get;}
IsConstructedGenericType Property bool IsConstructedGenericType {get;}
IsContextful Property bool IsContextful {get;}
IsEnum Property bool IsEnum {get;}
IsExplicitLayout Property bool IsExplicitLayout {get;}
IsGenericParameter Property bool IsGenericParameter {get;}
IsGenericType Property bool IsGenericType {get;}
IsGenericTypeDefinition Property bool IsGenericTypeDefinition {get;}
IsImport Property bool IsImport {get;}
IsInterface Property bool IsInterface {get;}
IsLayoutSequential Property bool IsLayoutSequential {get;}
IsMarshalByRef Property bool IsMarshalByRef {get;}
IsNested Property bool IsNested {get;}
IsNestedAssembly Property bool IsNestedAssembly {get;}
IsNestedFamANDAssem Property bool IsNestedFamANDAssem {get;}
IsNestedFamily Property bool IsNestedFamily {get;}
IsNestedFamORAssem Property bool IsNestedFamORAssem {get;}
IsNestedPrivate Property bool IsNestedPrivate {get;}
IsNestedPublic Property bool IsNestedPublic {get;}
IsNotPublic Property bool IsNotPublic {get;}
IsPointer Property bool IsPointer {get;}
IsPrimitive Property bool IsPrimitive {get;}
IsPublic Property bool IsPublic {get;}
IsSealed Property bool IsSealed {get;}
IsSecurityCritical Property bool IsSecurityCritical {get;}
IsSecuritySafeCritical Property bool IsSecuritySafeCritical {get;}
IsSecurityTransparent Property bool IsSecurityTransparent {get;}
IsSerializable Property bool IsSerializable {get;}
IsSpecialName Property bool IsSpecialName {get;}
IsUnicodeClass Property bool IsUnicodeClass {get;}
IsValueType Property bool IsValueType {get;}
IsVisible Property bool IsVisible {get;}
MemberType Property System.Reflection.MemberTypes MemberType {get;}
MetadataToken Property int MetadataToken {get;}
Module Property System.Reflection.Module Module {get;}
Name Property string Name {get;}
Namespace Property string Namespace {get;}
ReflectedType Property type ReflectedType {get;}
StructLayoutAttribute Property System.Runtime.InteropServices.StructLayoutAttribute StructLayoutAttribute {get;}
TypeHandle Property System.RuntimeTypeHandle TypeHandle {get;}
TypeInitializer Property System.Reflection.ConstructorInfo TypeInitializer {get;}
UnderlyingSystemType Property type UnderlyingSystemType {get;}
PS C:\
Managing Directory Security Principals in the .NET Framework 3.5
System.DirectoryServices
http://msdn.microsoft.com/en-us/magazine/cc135979.aspx
Building PowerShell binary Module using Visual Studio
.Net 'namespace' & 'classe' can direct interact in PowerShell Runspace (Console). Example is given above like "System.DirectoryServices". It is .Net name space. You can build your binary CMDLET using visual studio as well. See the below link for building PowerShell binary Module using Visual Studio.
http://blogs.msdn.com/b/saveenr/archive/2010/03/08/how-to-create-a-powershell-2-0-module-and-cmdlet-with-visual-studio-2010-screencast-included.aspx
(Saveen Reddy's blog)
How PowerShell Integration is worked with .Net
See the five series Blogs from "Hey, Scripting Guy! Blog".
http://blogs.technet.com/b/heyscriptingguy/archive/tags/-net/
How to write your own code using PowerShell ISE.
See the below snaps.
See that Namespace is coming automatically in the Visual Studio after putting the DOT(.)
See the class is coming automatically like visual studio after putting the DOT(.)
[system.directoryservices.activedirectory.domain]::GetCurrentDomain()
[system.directoryservices.activedirectory.domain]::GetCurrentDomain().DomainControllers
Few Examples of .NET namespace & classes with PowerShell
1. [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
2. [System.DirectoryServices.ActiveDirectory.forest]::GetCurrentforest()
3. Getting DCs
[system.directoryservices.activedirectory.domain]::GetCurrentDomain().DomainControllers
4. Exploring Active Directory Data Types with PowerShell .
http://blogs.technet.com/b/heyscriptingguy/archive/2013/07/24/exploring-active-directory-data-types-with-powershell.aspx
5.How to find Remote domain DCs:-
PS C:\>$DCs = new-object 'System.DirectoryServices.ActiveDirectory.DirectoryContext'("domain", "contoso.com" )
PS C:\>[System.DirectoryServices.ActiveDirectory.DomainController]::FindAll($DCs)
________________________________________________________________________________________________________________________________________________________
Regards
Biswajit Biswas
My Blogs|TechnetWiki Ninja