Posts

AD ports

  Port Protocol Service 53 TCP/UDP DNS 88 TCP/UDP Kerberos authentication 123 UDP W32Time 135 TCP RPC Endpoint Mapper 137/138 * UDP NetBIOS 139 * TCP NetBIOS 389 TCP/UDP LDAP 445 TCP SMB 464 TCP/UDP Kerberos password change 636 TCP LDAP SSL 3268/3269 TCP LDAP Global Catalog / LDAP GC SSL 49152-65535 TCP RPC Ephemeral Ports  

Powershell to add Domain Computer group in all GPO's

  $gpos = get-gpo -all foreach ($gpo in $gpos) { Set-GPPermissions -Name $gpo.DisplayName -PermissionLevel GpoRead -TargetName “Domain Computers” -TargetType Group }

DNS Audit about newly created records

  DNS Audit about newly created records $ComputerName = 'pugazh' $Zones = Get-DnsServerZone -ComputerName $ComputerName | Where-Object { $_.IsDsintegrated } #get all zones I care about $DNSRecords = $Zones | Get-DnsServerResourceRecord -ComputerName $ComputerName #get every DNS record          $RecordAndOwner = $DNSRecords | ForEach-Object {     [pscustomobject]@{         Record = $_         Owner   = (Get-Acl $('AD:\' + $_.DistinguishedName)).Owner     } }          $RecordAndOwner #List all the owners... wait, that is too much stuff and too hard to read          #List everyone that has created a DNS record and how many records they have created (only checks owner, but owner is the creator by default) $RecordAndOwner | Group-Object owner | Select-Object count, name | Sort-Object name          #Omit records created by se...

Powershell: Remove multiple users from a single AD group

 Remove multiple users from a single AD group https://www.powershellbros.com/remove-user-from-specifc-ad-groups-using-powershell/ Start-Transcript -Path C:\Temp\Remove-ADUsers.log -Append #Taking AD group member detail and will send them by Mail. #Getting AD group member detail and save in CSV format. (Get-ADGroup " AD-Group-Name " -properties members).members | Get-ADUser -properties displayName | Select-Object displayName,SamAccountName,emailaddress | export-CSV c:\users\administrator\ AD-Group-Name (or File-Name) .csv #Import the user list $Users = Import-Csv " C:\Temp\ Users.csv " #Update the AD group name which is need to be removed for listed users. $Group = “ AD-Group-Name ” $Report = @() foreach ($User in $Users) {     $UPN = $User.UserPrincipalName     $ADUser = Get-ADUser -Filter "UserPrincipalName -eq '$UPN'" | Select-Object SamAccountName         $ExistingGroups = Get-ADPrincipalGroupMembership $ADUser.SamAccountName | Select-Obje...

Event ID 1203 - check the ACL size for the object/s

 Event ID 1203 - check the ACL size for the object/s mentioned in the event ID.

DNS IP change

  $ComputerName = get-content " $env:USERPROFILE \desktop\servers.txt" $report = @() foreach ( $Computer in $ComputerName ) {               $Networks = Get-WmiObject -Class "win32_networkadapterconfiguration" -ComputerName $Computer      }    foreach ( $Network in $Networks ) {     $IPAddress   = $Network . IpAddress [ 0 ]     $SubnetMask   = $Network . IPSubnet [ 0 ]     $DefaultGateway = $Network . DefaultIPGateway     $DNSServers   = $Network . DNSServerSearchOrder             $MACAddress   = $Network . MACAddress       $OutputObj   = New-Object -Type PSObject     $OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $Computer . ToUpper(...

Homepath profile path set permission

  $csv = Import-Csv -Path "$env:userprofile\desktop\KDrivePath.csv"  ForEach ($item In $csv) {     $acl = Get-Acl $item.Path     $AddPerm = New-Object System.Security.AccessControl.FileSystemAccessRule($item.GroupName,"FullControl","ContainerInherit, ObjectInherit", "None","Allow")      $acl.SetAccessRule($AddPerm)     $acl | Set-Acl $item.Path     Write-Host -ForegroundColor Green "Group $($item.GroupName) created!" }