Skip to content

Commit 8221154

Browse files
committed
PSSA replace aliases
1 parent 732a938 commit 8221154

File tree

4 files changed

+20
-16
lines changed

4 files changed

+20
-16
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# This is ancient. I need to rewrite this, wherever it came from!
22
Import-Module ActiveDirectory
3-
Get-AdGroupMember "SourceGroupA-sAMAccountName" | %{Add-ADGroupMember -Identity "DestinationGroupB-sAMAccountName" -Members $_}
3+
Get-ADGroupMember 'SourceGroupA-sAMAccountName' | ForEach-Object {
4+
Add-ADGroupMember -Identity 'DestinationGroupB-sAMAccountName' -Members $_
5+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
$Users = Get-ADUser -Filter * -Properties DoesNotRequirePreauth | Where-Object {$_.DoesNotRequirePreauth -eq $True}
2-
$Users | Select-Object Name,SamAccountName,UserPrincipalName,DoesNotRequirePreauth | FT
1+
$Users = Get-ADUser -Filter * -Properties DoesNotRequirePreauth | Where-Object { $_.DoesNotRequirePreauth -eq $True }
2+
$Users | Select-Object Name, SamAccountName, UserPrincipalName, DoesNotRequirePreauth | Format-Table
33
$Users.Count
44

55
#Prevent accidental running before ready
66
break
77

88
# Turn off "DoesNotRequirePreauth" for all users.
9-
Get-ADUser -Filter * | Set-ADAccountControl -DoesNotRequirePreauth $False
9+
Get-ADUser -Filter * | Set-ADAccountControl -DoesNotRequirePreAuth $False
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
Import-Module ActiveDirectory
2-
Set-ADUser 'Bilbo Baggins' -Add @{drink="coffee"}
2+
Set-ADUser 'Bilbo Baggins' -Add @{drink = 'coffee' }
33
Get-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
2426
Import-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
3032
if ($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
3840
if ($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
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Get-adcomputer -SearchBase "OU=Member Servers,DC=DOMAINNAME,DC=org" `
2-
-Properties Name,ms-Mcs-AdmPwd,ms-Mcs-AdmPwdExpirationTime -Filter {Name -notlike "*xen*"} | `
3-
Select Name,ms-Mcs-AdmPwd,ms-Mcs-AdmPwdExpirationTime | Sort Name | Out-GridView
1+
Get-ADComputer -SearchBase 'OU=Member Servers,DC=DOMAINNAME,DC=org' `
2+
-Properties Name, ms-Mcs-AdmPwd, ms-Mcs-AdmPwdExpirationTime -Filter { Name -notlike '*xen*' } | `
3+
Select-Object Name, ms-Mcs-AdmPwd, ms-Mcs-AdmPwdExpirationTime | Sort-Object Name | Out-GridView

0 commit comments

Comments
 (0)