Created
June 21, 2016 18:48
-
-
Save Stephanevg/a29e353ac62040daf9d5285424ba8c10 to your computer and use it in GitHub Desktop.
Function to load the needed SCCM dll's that are needed to automate Application and enhanced detection rules with powershell. Call the function at the start of your sccript.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Load-ConfigMgrAssemblies { | |
Param( | |
$AdminConsoleDirectory = "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin" | |
) | |
#Add-Type -Path "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\DcmObjectModel.dll" | |
$filesToLoad = "Microsoft.ConfigurationManagement.ApplicationManagement.dll","AdminUI.WqlQueryEngine.dll", "AdminUI.DcmObjectWrapper.dll","DcmObjectModel.dll","AdminUI.AppManFoundation.dll","AdminUI.WqlQueryEngine.dll","Microsoft.ConfigurationManagement.ApplicationManagement.Extender.dll","Microsoft.ConfigurationManagement.ManagementProvider.dll","Microsoft.ConfigurationManagement.ApplicationManagement.MsiInstaller.dll" | |
Set-Location $AdminConsoleDirectory | |
[System.IO.Directory]::SetCurrentDirectory($AdminConsoleDirectory) | |
foreach($fileName in $filesToLoad) | |
{ | |
$fullAssemblyName = [System.IO.Path]::Combine($AdminConsoleDirectory, $fileName) | |
if([System.IO.File]::Exists($fullAssemblyName )) | |
{ | |
$FileLoaded = [Reflection.Assembly]::LoadFrom($fullAssemblyName ) | |
} | |
else | |
{ | |
Write-Host ([System.String]::Format("File not found {0}",$fileName )) -backgroundcolor "red" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment