I'm currently using the below code to convert NT format (NetBIOS) domain names to Distinguished name (DNS Domain name).
NameTranslate
object works great in my code... until I try to use the same code over my work VPN... resulting in an exception
The remote procedure call failed. (HRESULT: 0x800706BE)
I'm looking for an alternate way to do this (any way at all in a PowerShell script without having problems over VPN). I'm looking for a solution that doesn't require 3rd party PS modules or assembly dependencies, with the fewest lines of code.
$Domain = "SF"
$objTrans = New-Object -comObject "NameTranslate"
$objNT = $objTrans.GetType()
$objNT.InvokeMember("Init", "InvokeMethod", $Null, $objTrans, (3, $Null))
$objNT.InvokeMember("Set", "InvokeMethod", $Null, $objTrans, (3, "$Domain\"))
$DNSDomain = $objNT.InvokeMember("Get", "InvokeMethod", $Null, $objTrans, 1)
EDIT: For those who don't have much experience with NameTranslate (and also need a bigger picture what I'm trying to do):
I need to validate user-input'ed AD username/password, e.g., 'SF\MKANET' for the username. The best way I know to validate an AD account in PowerShell is with the below code. I need a programmatic way to take the "SF" this user-inputed text example; and, convert it to a format that can be used where $DNSDomain goes below. If someone has alternate solution with I could use to do the same thing, please let me know.
$DOM = New-Object System.DirectoryServices.DirectoryEntry($DNSDomain,$UserName,$Password)
if ($DOM.name -ne $null) {$CredentialValid = $True}
User contributions licensed under CC BY-SA 3.0