Home » Archive by category "Windows"

Get users Group and members of the groups

$AllUSers = get-aduser -filter {SamAccountName -like “z*” -and Enabled -eq $true } -Properties Memberof,EmployeeNumber -Server <Domain name> | ?{$PSItem.DistinguishedName -notmatch “OU=Service Accounts”} $results = new-object...

Get active Computers in Forest

$ForestInfo=Get-ADForest $Domains =$forestInfo.domains $FileName =$ForestInfo.RootDomain+”-Windows_Servers_60-9_Days_Active-“+”$(get-date -Format MM-dd-yyyy)”+”.csv” $FilePath = “c:\temp” $Daysactive = 60 $lastactive=(get-date).AddDays(-($Daysactive)) foreach($domain in $domains){ Write-Output “Working on $domain” Get-ADComputer -Filter {OperatingSystem -like...

Testing open ports With PowerShell

We can use PowerShell to test remote port connectivity without installing telnet and with the use of the Test-NetConnection command. To check if the remote...

Share folder permissions

#Share Folder Path $FolderPath = dir -Path “\\server1.vmwarenterprise.com\Reports\” -Recurse -Directory -Force$Report = @()Foreach ($Folder in $FolderPath) {$Acl = Get-Acl -Path $Folder.FullNameforeach ($Access in $acl.Access){$Properties =...

Get DC replication time response

foreach($d in (get-adforest).domains){$v = Measure-Command {get-addomaincontroller -Filter * -Server $d}Write-Output “Took $($v.TotalSeconds) to Enumerate DCS in $d “}

Created ISO image using PowerShell

Some Enterprise Organisations do not allow us to use any software on their networks a. Any software to be installed would need to be tested,...

Get AD user Properties across the forest

#get all AD users in forest with name like v- and status is enable $allusers = (get-adforest).domains| %{get-aduser -filter {SamAccountName -like “v-*” -and Enabled -eq...

Get DNS forwarder from forest

#Domain names in forest $ForestInfo = Get-ADForest$Domains =$forestInfo.domains$FileName = “DNSForwarder”+”$(get-date -Format MM-dd-yyyy)”+”.csv”$FilePath = “c:\temp”foreach($domain in $domains){Write-Output “Working on $domain”get-dnsserverforwarder -computer $domain| select IPAddress, @{l=”Domain”;e={$domain}}| Export-Csv...