Find existing UPN in Forest

A userPrincipalName (UPN) must be unique in a Active Directory Forest. To check for an existing UPN use the following lines. The powershell script expects that all DC’s within the Root Domain are GC enabled .

$RootDomain = "Contoso.com"
$DomainControllerRoot = (Get-ADDomainController -Filter * -server $RootDomain | select Hostname).hostname[0]
$GlobalCatalog = $DomainControllerRoot +":3268"
$UserPrincipalName = "Name@namespace.com"
if ((get-aduser -ldapfilter "(userPrincipalName=$UserPrincipalName)" -server $GlobalCatalog ).userPrincipalName.length -gt 0)
{
Write-host "UPN NOT unique in Forest : $UserPrincipalName "
}
Else
{
Write-host "UPN UNIQUE in Forest : $UserPrincipalName " 
}
Posted in Information Technology | Tagged , , | Comments Off on Find existing UPN in Forest

Force replication on all domain controller of a domain

The following line searches for all Domain Controllers of a Domain . Then it filters some Computers by IP (10.10.10.*) to eliminate RODCs and finally forces replication on each remaining Domain Controller.

$Domain = "Contoso.com"  
Get-ADDomainController -Filter * -server $Domain | where {$_.IPv4Address -notlike "10.10.10.*"} | foreach { repadmin /syncall /A /e /q $_.hostname}
Posted in Information Technology | Tagged , , | Comments Off on Force replication on all domain controller of a domain

List disk drives into an array

This Powershell script ist playing with an “athook” object based on an array having different named properties .

$Array = @()
Foreach ($vol In GET-WMIOBJECT win32_logicaldisk) 
 { 
 $obj = New-Object PSObject
 $Value = $vol.DeviceID
 $obj | Add-Member -MemberType NoteProperty -Name "Drive" -value $Value
 $Value =  $vol.Volumename
 $obj | Add-Member -MemberType NoteProperty -Name "Name" -value $Value
 $value = [math]::round(( $vol.Size/ 1073741824),0)
 $obj | Add-Member -MemberType NoteProperty -Name "SizeGB" -value $Value
 $value = [math]::round(( $vol.FreeSpace/ 1073741824),0)
 $obj | Add-Member -MemberType NoteProperty -Name "FreeGB" -value $Value
 $array += $obj
 }
$array  | out-gridview
Posted in Information Technology | Tagged | Comments Off on List disk drives into an array

Get Domain from distinguished Name

Get Domain from FQDN:

get-domfqdn “CN=Test,OU=Orgunit,DC=contoso,DC=test”

will result in

contoso.test

function get-domfqdn ($fqdn)
 {
 $afqdn= $fqdn.split(",")
 $first = 0
 $Dom=""
 foreach ($pfqdn in $afqdn)
  {
  If ($pfqdn.contains("DC=") -eq $true)
   {
   If ($first -eq 1)
    {
           $Dom = $Dom+"."
    }
   $first = 1
   $Dom = $Dom+$pfqdn.replace("DC=","")
   }
  }
 return $dom
 }
Posted in Information Technology | Tagged , , | Comments Off on Get Domain from distinguished Name

What ADDS Site

To find out in what ADDS site a computer is running use the following  command

nltest [/server:<remote computer name>] /dsgetsite
Posted in Information Technology | Tagged | Comments Off on What ADDS Site

What is NTLM

TechNet article written by Jesper Johansson explains NTLM

Security Watch The Most Misunderstood Windows Security Setting of All Time
https://technet.microsoft.com/en-us/library/2006.08.securitywatch.asp

Posted in Information Technology | Tagged | Comments Off on What is NTLM

Get OS Version from Windows Install medium

Find the wim file located in :\sources on the install medium then run a command shell as administrator.

dism /get-wiminfo /wimFile:<Drive>:\sources\<Wimfile>

As a result you should get something like this:

dism /get-wiminfo /wimfile:Y:\sources\boot.wim

Deployment Image Servicing and Management tool
 Version: 6.3.9600.17031

Details for image : Y:\sources\boot.wim

Index : 1
 Name : Microsoft Windows Recovery Environment (x64)
 Description : Microsoft Windows Recovery Environment (x64)
 Size : 1'956'357'322 bytes

The operation completed successfully.

Conclusion

This version number is pointing to  “Microsoft Windows 8.1, 6.3.9600.17031 (IR3)”

 

Posted in Tips | Tagged | Comments Off on Get OS Version from Windows Install medium