Powershell SCCM - 查询分发点配置以获取 pxe 是否启用未知计算机支持等

问题描述 投票:0回答:2

我制作了以下脚本:

cls

$siteCode = 'AB1'
$serverName = 'S203S1'

# Query SCCM to find the specific Distribution Point
$dp = Get-CMDistributionPoint -SiteSystemServerName $serverName
$dpProperties = $DP.EmbeddedProperties
if ($dpProperties) {
    $dpName = $dpProperties.Name
    $enablePxeSupport = $dpProperties.EnablePxeSupportForClients
    $allowPxeRequests = $dpProperties.RespondToPxeRequests
    $enableUnknownComputerSupport = $dpProperties.EnableUnknownComputerSupport

    Write-Host "Distribution Point Name: $dpName"
    Write-Host "Enable PXE support for clients: $enablePxeSupport"
    Write-Host "Allow this distribution point to respond to incoming PXE requests:     
    $allowPxeRequests"
    Write-Host "Enable unknown computer support: $enableUnknownComputerSupport"
    Write-Host '---------------------------------------------'
}
else {
    Write-Host 'Distribution Point not found.' -ForegroundColor Red
}

看起来

$dpproperties
不包含我正在寻找的3个值...我已经尝试过了:

Get-CMDistributionPointInfo | Select-Object -ExpandProperty Is Pxe 

但我没有找到其他两个值...... 有人可以告诉我我做错了什么吗?谢谢你的帮助

powershell sccm
2个回答
0
投票

在给定的脚本中,您已经快完成了。该问题与准确访问分发点的属性有关。您需要从

$DP.EmbeddedProperties
对象本身检索它们,而不是直接从
$dp
访问属性。

这是脚本的更正版本:

cls

$siteCode = 'AB1'
$serverName = 'S203S1'

# Query SCCM to locate the specific Distribution Point
$dp = Get-CMDistributionPoint -SiteSystemServerName $serverName
if ($dp) {
    $dpName = $dp.ServerNalPath
    $enablePxeSupport = $dp.IsPxeEnabled
    $allowPxeRequests = $dp.RespondToPxeRequests
    $enableUnknownComputerSupport = $dp.EnableUnknownComputerSupport

    Write-Host "Distribution Point Name: $dpName"
    Write-Host "Enable PXE support for clients: $enablePxeSupport"
    Write-Host "Allow this distribution point to respond to incoming PXE requests: $allowPxeRequests"
    Write-Host "Enable unknown computer support: $enableUnknownComputerSupport"
    Write-Host '---------------------------------------------'
}
else {
    Write-Host 'Distribution Point not found.' -ForegroundColor Red
}

在更正后的脚本中,我们直接利用

$dp
对象来访问属性,例如
ServerNalPath
(代表分发点名称)、
IsPxeEnabled
RespondToPxeRequests
EnableUnknownComputerSupport
。这些属性包含您正在寻找的信息。


0
投票

我认为您在这里混淆了两件事: EnableUnknownComputerSupport 是您分别在 der Add-Set-CMDistributionPoint 命令中使用的 cmdlet 参数名称(将该设置切换为 true)。

如果您查询 Get-CMDistributionPoint 的 EmbeddedProperties,但该属性称为 SupportUnknownMachines (您可以在 SMS_DistributionPointInfo 文档中看到这些属性的一些名称,不幸的是有些似乎也丢失了)。它是 SMS_EmbeddedProperty WMI 类型,因此您必须像这样访问它:

$enableUnknownComputerSupport = $dp.EmbeddedProperties.SupportUnknownMachines.Value

由于 SMS_EmbeddedProperty 似乎不支持布尔值,它是一个整数,但我假设它只是 1 表示启用,0 表示禁用(我无法在我们的系统中确认这一点,因为我们没有启用该设置的 DP)。

© www.soinside.com 2019 - 2024. All rights reserved.