Skip to content

Instantly share code, notes, and snippets.

@codaamok
codaamok / Connect-CMDrive
Created October 24, 2019 18:56
Add to your profile. Quickly import SCCM module and connect to PS drive.
Function Connect-CMDrive {
param(
# SMS provider or site server
[Parameter(Mandatory=$false, Position = 0)]
[ValidateScript({
If(!(Test-Connection -ComputerName $_ -Count 1 -ErrorAction SilentlyContinue)) {
throw "Host `"$($_)`" is unreachable"
} Else {
return $true
}
@codaamok
codaamok / Get enabled CIs for Windows 10 appx DisplayName deprovisioning
Last active August 28, 2019 15:07
If you use the Windows Admins GitHub CI to deprovision some Windows 10 apps you can use this to get all the DisplayName values of only those that are enabled: https://github.com/winadminsdotorg/SystemCenterConfigMgr/blob/master/Compliance%20Settings/CIs/Client%20Configuration/CB%20-%20Deprovisioned%20AppX%20via%20PoSh.cab
Get-CMConfigurationItem | Where-Object { $_.LocalizedDisplayName -like "CI - Deprovisioned AppX -*" -And $_.InUse -eq $true } | Select-Object LocalizedDisplayName,@{Name="AppName";Expression={[Regex]::Matches($_.SDMPackageXML,"\`$_\.DisplayName -Match ('.+')").Groups[1].Value}}
@codaamok
codaamok / CompareFilteringOptions.ps1
Last active March 17, 2020 15:27
17/03/2020 update: thanks @indented-automation. Snippet to compare various filter options. Linked here: https://www.cookadam.co.uk/get-cmunusedsources
$winFiles = Get-ChildItem c:\windows -Recurse -ErrorAction SilentlyContinue
$commands = @{
'Where-Object' = {
$exeFiles = $winFiles | Where-Object { $_.Extension -eq ".exe" }
}
'Where-Object (no script block)' = {
$exeFiles = $winFiles | Where-Object Extension -eq ".exe"
}
'.Where' = {