I recently wanted to run some PowerShell code remotely, but a requirement of this is that WinRM is enabled on the remote device. So we needed to work out how to enable windows remote management (WinRM) on remote devices….without using … Continue reading →
When using Test-Path to query the HKEY_USERS (or HKU) hive, it kept returning false even if the hive existed. This post explains how to use Test-Path for HKEY_USERS, and the modifications that we need to make. How to use Test-Path for … Continue reading →
LDAP does not return all Active Directory group members if there are more than 1500 members in the group. It will return the first 1500, but none thereafter. LDAP Does Not Return All Active Directory Group Members Luckily when a … Continue reading →
This post discusses how we can search Active Directory using PowerShell ADSISearcher filters. Using search filters can improve search performance significantly. Consider the following where we create a default ADSISearcher to begin searching Active Directory (AD): $objSearcher=[adsisearcher]”” If we used … Continue reading →
This post provides a simple example of how we can export data to a CSV and maintain the column order: $csvFile = “c:\temp\alkane.csv” $exampledata = @(@(“John”,”37″),@(“Peter”,”14″),@(“Michelle”,”22″),@(“Abdul”,”31″),@(“Roger”,”22″),@(“Rachel”,”50″)) $csvwrapper = @() foreach($person in $exampledata) { $name = $person[0] $age = $person[1] #append … Continue reading →
This post provides a simple example of how we can use PowerShell ADSI to search groups in Active Directory. You may wish to further optimise this by using LDAP filters. #only groups $objSearcher=[adsisearcher]'(&(objectCategory=group))’ $objSearcher.PageSize = 200 #specify properties to include … Continue reading →
This post provides a simple example of how we can use PowerShell ADSI to search computers in Active Directory. You may wish to further optimise this by using LDAP filters. #only computers $objSearcher=[adsisearcher]'(&(objectCategory=computer))’ $objSearcher.PageSize = 200 #specify properties to include … Continue reading →
This post provides a simple example of how we can use PowerShell ADSI to search users in Active Directory. You may wish to further optimise this by using LDAP filters. $searcher=[adsisearcher]'(&(objectCategory=person)(objectClass=user))’ $searcher.PageSize = 200 $colProplist = “samaccountname” foreach ($i in … Continue reading →
This post provides an example of how we can use PowerShell and ADSI to add, update, clear and append Active Directory attributes. Use Put() to Set an Active Directory Attribute using PowerShell In its simplest form, we can use the … Continue reading →
This is a simple script to list AD sites and subnets using PowerShell. $sites = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites foreach ($site in $sites) { write-host “(site) $site” foreach ($subnet in $site.Subnets) { write-host “….(subnet) $subnet” foreach ($server in $site.Servers) { write-host “……..(server) $server” … Continue reading →