How automatically set DSRM password or something like that via Powershell

function set-DSRMPass {
Begin {write-host „`n“
Write-Host -ForeGroundColor Yellow „Set new DSRM password …… “ ;
}
Process {

#$ntdspasschange = ‚ntdsutil „set dsrm password“ „reset password on server null“‚
#invoke-expression $ntdspasschange

$pass = Read-Host „password“ -AsSecureString
$wshell = New-Object -ComObject wscript.shell;
$wshell.Run(„cmd.exe“)
sleep 5
$wshell.SendKeys(‚ntdsutil‘)
$wshell.SendKeys(‚{ENTER}‘)
sleep 5
$wshell.SendKeys(‚set dsrm password‘)
$wshell.SendKeys(‚{ENTER}‘)
sleep 5
$wshell.SendKeys(„reset password on server null“)
$wshell.SendKeys(‚{ENTER}‘)
$wshell.SendKeys(„$pass“)
$wshell.SendKeys(‚{ENTER}‘)
sleep 5
$wshell.SendKeys(„$pass“)
$wshell.SendKeys(‚{ENTER}‘)
$wshell.SendKeys(‚q‘)
$wshell.SendKeys(‚{ENTER}‘)
$wshell.SendKeys(‚q‘)
$wshell.SendKeys(‚{ENTER}‘)
}
#ntdsutil „set dsrm password“ „reset password on server null“ q q

}

 

 

 

 

 

marwin se představuje:

IT Engineer Design, Implementation and Administration of Microsoft products. Active Directory and MS Exchange systems, Hyper-V, SCOM
Příspěvek byl publikován v rubrice Powershell. Můžete si uložit jeho odkaz mezi své oblíbené záložky.