Posts

Showing posts from January, 2023

Move bulk Computer object to OU using CSV file.

  $ComputersPath= Import-Csv -Path "D:\XYZ\Computers.csv" $TargetOU = "OU=WorkStations,DC=bbn,DC=com" foreach ($item in $ComputersPath) {     $computer = Get-ADComputer $item.CompName     Move-ADObject -Identity $computer.DistinguishedName -TargetPath $TargetOU -Confirm:$false     Write-Host Computer account $computer.Name has been moved successfully }

Check if the AD recycle bin is enabled or not

  Get-ADOptionalFeature -Filter * -Server "bbn.com"

Get-ADGroupmember - Powershell command to export AD Security group members

  Get-ADGroupmember -Identity "Administrators" -Server "appcorp.ca" | Select name, samaccountname | export-csv c:\Temp\Administrators_Admins.csv

Get-ADComputers lastlogon date using input file and export a CSV file.

  $Computer = Import-Csv -path “C:\Temp\computers.csv” $Computer| foreach{Get-ADComputer -Identity $_.name -Properties * |select name, samaccountname, LastLogonDate} | Export-Csv output.csv -NoTypeInformation Input csv  Header: Name

Get-ADGroupmember using powershell

  Get-ADGroupMember -Server "abc.com" -Identity "Domain Admins" -Recursive | Get-ADUser | Select Name, samaccountname, Enabled | export-csv c:\Temp\Domain-Admins.csv

Export all GPO in HTML report

  Get-GPOReport -All -Domain "abc.com" -ReportType html -Path "C:\Temp\GPOReportsAll.html"