Skip to content

Instantly share code, notes, and snippets.

View Robert-LTH's full-sized avatar
🎯
Focusing

Robert Johnsson Robert-LTH

🎯
Focusing
View GitHub Profile
# (Get-CimClass -Namespace root\ccm -ClassName sms_client).CimClassMethods['ResetPolicy'].Parameters
Invoke-CimMethod -Namespace root\ccm -ClassName sms_client -Name ResetPolicy -Arguments @{ uFlags = ([UInt32]1) }
Restart-Service CcmExec
<#
# https://blogs.technet.microsoft.com/charlesa_us/2015/03/07/triggering-configmgr-client-actions-with-wmic-without-pesky-right-click-tools/
# {00000000-0000-0000-0000-000000000001} Hardware Inventory
# {00000000-0000-0000-0000-000000000002} Software Inventory
# {00000000-0000-0000-0000-000000000003} Discovery Inventory
# {00000000-0000-0000-0000-000000000010} File Collection
# {00000000-0000-0000-0000-000000000011} IDMIF Collection
# {00000000-0000-0000-0000-000000000012} Client Machine Authentication
# {00000000-0000-0000-0000-000000000021} Request Machine Assignments
# {00000000-0000-0000-0000-000000000022} Evaluate Machine Policies
get-ScheduledTask -TaskName "Configuration Manager Client Ugrade" | Start-ScheduledTask -Verbose
function Get-ContentIDToAppName {
param (
$ContentID,
$ContentRevision = 1,
$SiteServer,
$Namespace
)
$AllInfo = Get-WmiObject -ComputerName $SiteServer -Namespace $Namespace -Query "SELECT SMS_Application.LocalizedDisplayName,SMS_CIToContent.ModelName FROM SMS_CIToContent INNER JOIN SMS_Application ON SMS_CIToContent.SecuredModelName = SMS_Application.ModelName WHERE SMS_CIToContent.ContentUniqueID = '$ContentID' AND SMS_CIToContent.ContentVersion = '$ContentRevision'"
New-Object -TypeName PSObject @{
ApplicationName = $AllInfo.SMS_Application.LocalizedDisplayName
function New-ExplorerContextMenuEntry {
param(
$Identifier,
$icon,
$MenuText,
$command,
$Class
)
$OldLocation = Get-Location
param(
[string]$ExitCode
)
# http://www.msierrors.com/drivers/dpinst-exit-codes-explained/
$DPInstInfo = New-Object psobject @{
PackageInstallationFailure = $false
RebootRequired = $false
<#
function Load-Module {
param(
$ModuleName,
[switch]$Force
)
$Params = @{
ErrorAction = 'Stop'
}
if ($Force.IsPresent) {
$Params.Add('Force',$true)
@Robert-LTH
Robert-LTH / WMI method parameters.ps1
Created May 1, 2019 22:48
The order of WMI method parameters is a pain!
$MethodClass = [WmiClass]"\\COMPUTERNAME\NAMESPACE:CLASS"
$Method = "MethodName"
$InParams = $MethodClass.psbase.GetMethodParameters($Method)
$InParams.PSBase.properties | select Name,Value | format-Table
# Set the parameters with $InParams.Property = ""
# and invoke as follows
$Result = $MethodClass.InvokeMethod($Method, $InParams, $null)
$Result
@Robert-LTH
Robert-LTH / Invoke-SCCMRunScript.ps1
Last active September 3, 2023 15:56
Simple script to use the new sccm feature called "Run Script". The builtin Invoke-CMScript does not accept parameters.
<#
Thank you CodyMathis123 (https://github.com/CodyMathis123) for adding ParameterSets to do it the right way!
Updated 2022-08-22 thanks to Bryan Dam who noticed that the XML definition was changed and Type became DataType.
Also renamed function because SCCM is the old name of the product.
#>
<#
.SYNOPSIS
Run a script with custom parameters over WMI in ConfigMgr
.DESCRIPTION
param(
[string]$BaselineName
)
$ErrorActionPreference = "Stop"
try {
$Params = @{
Namespace = 'ROOT\ccm\Policy\Machine\ActualConfig'
ClassName = 'CCM_DCMCIAssignment'