Change PXE Password on all DP’s

Have you ever tried to change the PXE password for your DP’s??

it is easy isn’t it?!?!?! go to the properties of your DP and change the password there…

but if you have 100+ DP’s, it will take a bit of time, don’t it?

This is what happen with a good friend of mine and he asked help…

if you’re in the same situation, the following powershell script is here to help :) , you’ll only need to change the sdkserver, sitecode and password to the values you want

$sdkserver=”SDKSERVERNAME”
$sitecode=”SITECODE”
$password=”PASSWORD”
$property=”PXEPassword”

$passwordclass = [wmiclass]“”
$passwordclass.psbase.Path = “\\” + $sdkserver + “\ROOT\SMS\site_” + $SiteCode + “:SMS_Site”

$inParams = $passwordclass.GetMethodParameters(“EncryptDataEx”)
$inParams["Data"] = $password
$inParams["SiteCode"] = $SiteCode
$outParams = $passwordclass.InvokeMethod(“EncryptDataEx”, $inParams, $null)
$PXEpassword = $outParams.EncryptedData.ToString()
#Write-Output “PXE Password is set to the following encrypted value: ” $PXEpassword

$listofDP = gwmi -computer $sdkserver -namespace “root\sms\site_$sitecode” -query “select * from SMS_SCI_SysResUse where RoleName = ‘SMS Distribution Point’”
foreach ($dp in $listofDP)
{
$dpname = $dp.NetworkOSPath -replace(“\\”,””)

$dp = gwmi -computer $sdkserver -namespace “root\sms\site_$sitecode” -query “select * from SMS_SCI_SysResUse where NetworkOSPath = ‘\\\\$dpname’ and RoleName = ‘SMS Distribution Point’”

$props = $dp.Props
$prop = $props | where {$_.PropertyName -eq $property}

$prop.Value = 0
$prop.Value1 = $PXEpassword
$prop.Value2 = $null

$dp.Props = $props
$dp.Put()
}

hope this will help you

 

email

Written by , Posted .