AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 832745
Accepted
kimo pryvt
kimo pryvt
Asked: 2017-02-16 08:58:40 +0800 CST2017-02-16 08:58:40 +0800 CST 2017-02-16 08:58:40 +0800 CST

通过 powershell、命令行或 WMI 将 SCCM 应用程序安装到客户端

  • 772

我正在尝试在 powershell 中创建一个脚本,该脚本请求并为 sccm 应用程序目录中的用户或计算机安装可用的应用程序。

我知道有一种方法可以使用 wmi 方法强制 sccm 客户端操作。

例子

WMIC /namespace:\\root\ccm path sms_client CALL TriggerSchedule "{00000000-0000-0000-0000-000000000003}" /NOINTERACTIVE

有一种方法可以通过在用户计算机中执行 wmi 方法或命令行来强制安装应用程序。

powershell wmi application sccm-2012
  • 1 1 个回答
  • 3770 Views

1 个回答

  • Voted
  1. Best Answer
    Paul G
    2017-02-25T13:47:00+08:002017-02-25T13:47:00+08:00

    如果您有兴趣,这是 vbscript 中的解决方案。我还不精通powershell,但我做了很多SCCM的.net和vbscript自动化。我敢肯定这里有人可以翻译成powershell。

    'Declare WMI connection to CCM, temporarily disable errors so the script doesnt stop if the namespace doesn't exist.  We will handle the error next.
    
    On Error Resume Next
          Dim oWMI : Set oWMI = GetObject("winmgmts:\\.\root\ccm\ClientSDK")
    On Error Goto 0
    
    ' Check the datatype of oWMI to make sure its not null for error handling.
    
    If VarType(oWMI) > 1 Then 
    
        'Run a query for all applications
        Dim colItems, objItem : Set colItems = oWMI.ExecQuery("Select * from CCM_Application")
    
        'Same as above... error handling in case nothing was returned
        If VarType(colItems) > 1 Then 
    
        ' Iterate through all the applications available
            For Each objItem in colItems
                Wscript.Echo "Application: " & objItem.FullName & vbCr & _ 
                "Description: " & objItem.Description & VbCr & _ 
                "Publisher: " & objItem.Publisher & VbCr & _ 
                "Version: " & objItem.SoftwareVersion & VbCr & _ 
                "Install State: " & objItem.InstallState & VbCr & _ 
                "Id: " & objItem.Id & VbCr & _ 
                "Revision: " & objItem.Revision
    
                'In my example, if the application is Adobe Air then run the install action
    
                If objItem.FullName = "Adobe Air" and ObjItem.InstallState = "NotInstalled" Then
    
                    'First three parameters identify the application (id, revision, and ismachinetarget).  The Next 3 are EnforcePreference, Priority and IsRebootIfNeeded options.
                    '0, "Foreground", "False" sets immediate foreground install with no reboot
                    'See the msdn page for info about what other options you can set: https://msdn.microsoft.com/library/jj902780.aspx
    
                    Dim ReturnCode : ReturnCode = objItem.Install(objItem.Id, objItem.Revision, objItem.IsMachineTarget, 0, "Foreground", "False")
    
                    'Returns 0 if it successfully started the install.  This does NOT return the exit code of the installation itself.
    
                    Wscript.Echo "Return Code: " & ReturnCode
    
                End If
            Next
    
        End If
    
    End If
    
    • 2

相关问题

  • 资源锁和电源外壳

  • 脚本 - 如何断开远程桌面会话?

  • 如何限制向通讯组发送到外部地址?

  • Powershell对值与数组的作用不同?

  • Windows Powershell Vim 键绑定

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve