Change PXE Password on all DP’s

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

 

About

Raphael is a 9 times Microsoft MVP with over 20 years of experience in IT, in which 13 years have been dedicated to System Center and Automation. His extended experience has been developed through several IT roles, from first-line support to principal consultant, towards a wide range of clients and sectors. One of the four MVPs in Enterprise Client Management in the UK, Raphael holds more than 30 Microsoft certifications and is an MCT (Microsoft Certified Trainer). Since 2008, Raphael has been providing Microsoft trainings from basic to advanced levels in several categories. Throughout his career, Raphael has joined as speaker in well-known events such as TechEd and Gartner Security Risk Management. He also organised community events and lectured around the world, sharing best practices and knowledge within the industry. Bilingual in English and Portuguese, Raphael has authored diverse articles published in Microsoft's TechEd, served as the editor-in-chief of a magazine focused on System Center in Brazil and wrote two books: "Understanding System Center 2012 SP1 Configuration Manager: The walkthrough book" and "System Center 2012 R2 Configuration Manager: Automation from Zero to Hero".

Tagged with: , , , ,