Skip to content

Josh's IT-Blog

Information Technology, and other interesting things …

  • Home
  • About
  • Contact
  • Links
  • Home
  • About
  • Contact
  • Links

pass parameter values to Invoke-CMScript

  1. Home   »  
  2. pass parameter values to Invoke-CMScript

pass parameter values to Invoke-CMScript

30. July 201920. October 2020 Burkard JoshSCCM, System Center

The Invoke-CMScript cmdlet invokes a PowerShell script in Microsoft System Center Configuration Manager. System Center Configuration Manager has an integrated ability to run Powershell scripts. The scripts simplify building custom tools to administer software and let you accomplish mundane tasks quickly, allowing you to get large jobs done more easily and more consistently. For more information, see Create and run PowerShell scripts from the Configuration Manager console.

unfortunately the Invoke-CMScript doesn’t allow to pass values to defined  script params. if you want to do this, you have to invoke the script through the Configuration Manager console.

now i wrote the PowerShell function Invoke-SCCMScript, which allow to pass values to the CMScripts. you can find the function Invoke-SCCMScript at https://github.com/joshburkard/SCCM/blob/master/Invoke-SCCMScript.ps1

this is an example, how to use it:

# parameters to send to the script
$InputParameters = @{
    param1 = 'Test 1'
    param2 = 'Test 2'
}

$Params = @{
    SiteServer        = 'server.fqdn.net'
    SiteCode          = 'P00'
    ScriptName        = 'Test Script'
    TargetResourceIDs = '11111111'
    InputParameters   = $InputParameters
}
Invoke-SCCMScript @Params

 

Post navigation

Previous: PowerShell and PSHTML in Azure Function App
Next: Pester tests for PowerShell modules

About

Author Image
My name is Josh Burkard.
I'm a DevOps Engineer working with one of Europees largest payroll provider. in my work I have a lot to do with Microsoft server operating systems, System Center, VMware, Microsoft Azure Cloud and other software.
On this site I will write some posts about different technology problems and their solutions.
please note also my tweets and retweets from this area.

Categories

  • General (13)
  • Hardware (9)
    • Network (8)
      • Cisco (2)
    • Storage (2)
  • Hiking (1)
  • Home Assistant (5)
  • Microsoft Azure (1)
    • Automation (1)
  • PowerShell (3)
  • Software (1)
    • Excel (1)
  • System Center (18)
    • SCCM (3)
    • SCDPM (1)
    • SCOM (12)
    • SCSM (1)
    • SMA (1)
  • VMware (8)
  • Windows 2008 R2 (10)
    • Active Directory (7)
  • Windows 2012 R2 (1)
  • Windows 2016 (1)
  • Windows 7 (4)
    • BitLocker (1)
  • WordPress (1)
Proudly powered by WordPress | Theme: goldy-mex by inverstheme.