简体   繁体   English

SCCM 基线合规性 - 用于报告目的的 Powershell 脚本输出

[英]SCCM Baseline compliance - Output from Powershell script for reporting purposes

I am trying to create a report of what version of .NET is instlaled over the estate, but I can't edit .mof file for SCCM inventory... I need to do it massively - standalone Powershell can't aid me, since it can't connect to remote registry in this environment...but SCCM can do it.我正在尝试创建一份报告,说明在该资产上安装了哪个版本的 .NET,但我无法编辑 SCCM 库存的 .mof 文件...我需要大量执行此操作 - 独立的 Powershell 无法帮助我,因为在这种环境下它无法连接到远程注册表……但 SCCM 可以做到。

What I thought would be a good idea - Create baseline that will scan the estate, get the data and then I'd report it.我认为是个好主意 - 创建基线来扫描遗产,获取数据,然后我会报告它。

I have found a really awesome script https://github.com/EliteLoser/DotNetVersionLister - this is how output looks:我发现了一个非常棒的脚本https://github.com/EliteLoser/DotNetVersionLister - 这是输出的样子:

ComputerName : localhost
>=4.x        : 4.6.2
v4\Client    : Installed
v4\Full      : Installed
v3.5         : Not installed (no key)
v3.0         : Not installed (no key)
v2.0.50727   : Not installed (no key)
v1.1.4322    : Not installed (no key)
Ping         : True
Error        : 

As you can see output is vast.正如你所看到的,输出是巨大的。 I've made a small script that imports this module, runs it against localhost and it's awesome, but...how to report this?我制作了一个导入这个模块的小脚本,在本地主机上运行它,它很棒,但是......如何报告这个?

I've added it to SCCM, made baseline to use this but do anyone know how, and if it is even possible, to make a report/query or anything out from it, that would return the same output from above, per each computer in my collection?我已将其添加到 SCCM,为使用此设置了基线,但是否有人知道如何(如果可能的话)制作报告/查询或从中生成任何内容,这将在每台计算机上从上面返回相同的输出在我的收藏中?

I don't know if it's exactly what you are looking for, but I signed up to throw an idea your way that you might find useful.我不知道这是否正是您要找的东西,但我注册了,以您可能认为有用的方式提出一个想法。

You can setup a baseline config to run your script and have it write the output to the host.您可以设置基线配置来运行您的脚本并将输出写入主机。 For this to work, you have to make the compliance condition be non-compliant.为此,您必须使合规条件不合规。 So set the compliance condition that the script returns an impossible value so it will be non-compliant.所以设置合规条件,让脚本返回一个不可能的值,这样它将是不合规的。

Then in SQL management studio, you can query the baseline config and see the output results of every system.然后在SQL management studio中,可以查询baseline config,查看各个系统的输出结果。

Here's an example baseline config script.这是一个示例基线配置脚本。 In this one we check if some folders exist and write output based on the results, this is just to show you an example, use your test script that you setup to write your output to the host:在这个中,我们检查是否存在某些文件夹并根据结果写入输出,这只是向您展示一个示例,使用您设置的测试脚本将输出写入主机:

if (Test-Path -Path "C:\Windows") {
    if (Test-Path -Path "C:\Windows\Debug") {
        "Debug"
    }
    if (Test-Path -Path "C:\Windows\System") {
        "System"
    }
    if (Test-Path -Path "C:\Windows\System32") {
        "System32"
    }
    if (Test-Path -Path "C:\Windows\Nothing") {
        "Nothing"
    }
} else {
    "NOT INSTALLED"
}

Create a baseline for this and deploy it to some test systems.为此创建一个基线并将其部署到一些测试系统。 After the test systems evaluate and report results back, you can go to your sql management studio connected to your sccm database and run this sql command.在测试系统评估并报告结果后,您可以转到连接到 sccm 数据库的 sql 管理工作室并运行此 sql 命令。 Modify it with the exact name of your configuration item you created:使用您创建的配置项的确切名称对其进行修改:

Select csd.Netbios_Name0, csd.ConfigurationItemName, csd.CurrentValue, csd.Criteria, csd.LastComplianceMessageTime, csd.CIVersion
From v_CIComplianceStatusDetail csd
Where csd.ConfigurationItemName = 'YourConfigurationItemNameHere'
Order By csd.CurrentValue   

The results return like this结果像这样返回

Hopefully this gives you some ideas you can run with.希望这能给你一些可以运行的想法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM