Right so essentially I am storing a domain name into a variable - which then I need to split up later in my code into it's individual parts i.e.
$domainName = "testdomain.co.uk"
$domainNameSplit = $domainName.split(".")
echo $domainNameSplit[0]
echo $domainNameSplit[1]
echo $domainNameSplit[2]
In this instance it's fine as I know it's a .co.uk so will have 3 parts - however my code allows for input and therefore may take a testdomain.local format instead. How can I look through the $domainName variable and find the number of '.' in order to know what to do with it?
I also need to then use it in order to create a $ou variable to work with, so:
$ou = "DC=WhatWouldIPutHere?,DC=AndHere"
Thanks!