Category Archives: Active Directory

Testing replication

We’ve seen a few things we can do with the WMI provider for Active Directory. One of the most useful is testing replication function test-replication{ [CmdletBinding()] param( [string]$computername=$env:COMPUTERNAME ) Get-WmiObject -Namespace root\MicrosoftActiveDirectory -Class MSAD_ReplNeighbor -ComputerName $computername| select SourceDsaCN, NamingContextDN, @{N=”LastSyncAttempt”; … Continue reading

Posted in Active Directory, Powershell, PowerShell and WMI | 2 Comments

Test for domain membership

Quick function to determine if a given machine is in a domain or workgroup function test-domain{ [CmdletBinding()] param ( [parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string]$computer=”.” ) BEGIN{}#begin PROCESS{ Get-WmiObject -Class Win32_ComputerSystem -ComputerName $computer | select Name, Domain }#process END{}#end } Feed … Continue reading

Posted in Active Directory, PowerShell and WMI | Leave a comment

Find the Time Server

No its not the latest Internet game. Active Directory synchronises the computer clock times. To know what server is being used function get-timeserver{ [CmdletBinding(SupportsShouldProcess=$true)] param ( [parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string]$computer ) BEGIN{ $HKLM = 2147483650 }#begin PROCESS{ $reg = … Continue reading

Posted in Active Directory, PowerShell and WMI | Leave a comment

Clearing AD logging

Last time we looked at turning on logging – for one or more criteria. The normal state of diagnostic logging is None i.e. the options are set to zero. If we have only a few options set we can use … Continue reading

Posted in Active Directory, PowerShell and WMI | Leave a comment

Setting AD logging

Now that we know what the options are we can look at switching them on. function set-logsetting{ [CmdletBinding(SupportsShouldProcess=$true)] param ( [parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string]$computer, [string]$setting, [ValidateRange(0,5)] [int]$level ) BEGIN{ $HKLM = 2147483650 }#begin PROCESS{ if ($logtype.Values -notcontains $setting){ Throw … Continue reading

Posted in Active Directory, PowerShell and WMI | Leave a comment

Logging options

With 24 logging options to choose from its difficult to keep track of them. We already have the data in a ash table so lets just display it function get-logsettingoptions{ PROCESS{ 1..$logtype.Count | foreach { $logtype["$_"] } }#process END{}#end <# … Continue reading

Posted in Active Directory, PowerShell and WMI | Leave a comment

Active Directory Logging

I had a problem come up recently where I needed to check the level of logging applied to the AD database. This is configurable via registry settings. See http://support.microsoft.com/kb/314980 for details. Checking one machine is OK by RDP but when … Continue reading

Posted in Active Directory, PowerShell and WMI | Leave a comment

Setting Security permissions on an AD group

We saw how to create an AD security group here http://msmvps.com/blogs/richardsiddaway/archive/2011/06/28/creating-ad-security-groups.aspx   This is how we can give a user full control of that group function set-groupsecurity { [CmdletBinding()] param ( [string]$name ) $dom = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain() $root = $dom.GetDirectoryEntry() $search … Continue reading

Posted in Active Directory, Active Directory administration with PowerShell, PowerShell and Active Directory | Leave a comment

Creating AD security groups

Continuing my AD excursion for a while. I saw a forum post about creating AD groups and came up with this function function new-securitygroup { [CmdletBinding()] param ( [string]$name, [string]$ou, [parameter(ParameterSetName="U")] [switch]$universal, [parameter(ParameterSetName="G")] [switch]$global, [parameter(ParameterSetName="DL")] [switch]$domainlocal ) $rootdse = [ADSI]“” … Continue reading

Posted in Active Directory, Active Directory administration with PowerShell, PowerShell and Active Directory | Leave a comment

Domain Controllers

I found this part completed post & can’t remember if I ever published it.  If I did we’ll put it down to my forgetfulness. The role of Domain Controllers in an Active Directory environment still seems to be causing problems … Continue reading

Posted in Active Directory | Leave a comment