11Import-Module ActiveDirectory
2- Set-ADUser ' Bilbo Baggins' - Add @ {drink = " coffee" }
2+ Set-ADUser ' Bilbo Baggins' - Add @ {drink = ' coffee' }
33Get-ADUser ' Bilbo Baggins' - Properties drink | Select-Object *
44
55$Users = Get-ADUser - Filter ' Enabled -eq $true' - Properties drink
6- $Drinks = $Users | Group drink
6+ $Drinks = $Users | Group-Object drink
77$Drinks
88
99$SchemaPath = (Get-ADRootDSE ).schemaNamingContext
1010$DrinkSchema = Get-ADObject - Filter ' Name -like "drink"' - SearchBase $SchemaPath - Properties *
11+ [void ]$DrinkSchema
1112$UserSchema = Get-ADObject - Filter ' Name -like "user"' - SearchBase $SchemaPath - Properties *
1213$PersonSchema = Get-ADObject - Filter ' Name -like "person"' - SearchBase $SchemaPath - Properties *
14+ [void ]$PersonSchema
1315$Attributes = @ ()
1416$Attributes += $UserSchema.maycontain
1517$Attributes += $userSchema.systemMayContain
1618$Attributes += $UserSchema.auxiliaryClass
1719$Attributes += $UserSchema.systemAuxiliaryClass
18- $Attributes = $Attributes | Sort
20+ $Attributes = $Attributes | Sort-Object
1921
2022$Attributes
2123$UserSchema.AddedProperties
@@ -24,19 +26,19 @@ $UserSchema.AddedProperties
2426Import-Module ActiveDirectory
2527
2628# Get the schema object for the drink attribute
27- $schemaObject = Get-ADObject - Filter {name -eq ' drink' } - SearchBase (Get-ADRootDSE ).schemaNamingContext - Properties isDefunct
29+ $schemaObject = Get-ADObject - Filter { name -eq ' drink' } - SearchBase (Get-ADRootDSE ).schemaNamingContext - Properties isDefunct
2830
2931# Check if the drink attribute is enabled in the schema
3032if ($schemaObject.isDefunct ) {
31- Write-Output " The drink attribute is not enabled."
33+ Write-Output ' The drink attribute is not enabled.'
3234} else {
33- Write-Output " The drink attribute is enabled."
35+ Write-Output ' The drink attribute is enabled.'
3436}
3537
3638# Check if the drink attribute is added to the user class
37- $userClass = Get-ADObject - Filter {name -eq ' user' } - SearchBase (Get-ADRootDSE ).schemaNamingContext - Properties mayContain
39+ $userClass = Get-ADObject - Filter { name -eq ' user' } - SearchBase (Get-ADRootDSE ).schemaNamingContext - Properties mayContain
3840if ($userClass.mayContain -contains ' drink' ) {
39- Write-Output " The drink attribute is added to the user class."
41+ Write-Output ' The drink attribute is added to the user class.'
4042} else {
41- Write-Output " The drink attribute is not added to the user class."
43+ Write-Output ' The drink attribute is not added to the user class.'
4244}
0 commit comments