Skip to content

Instantly share code, notes, and snippets.

@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 / 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
}
function Copy-CMTSDeployments {
<#
.SYNOPSIS
A function to copy deployments from one task sequence to another. Modify the New-CMTaskSequenceDeployment parameters in the splat as desired.
.EXAMPLE
PS C:\> Copy-CMTSDeployments -taskSequenceId_old "ABC0037A" -taskSequenceId_new "ABC004EA" -ExcludeCollections "ABC0133F", "ABC01340"
Gathers all deployments from task sequence ABC0037A and deploys them to ABC004EA, excluding ABC0133F and ABC01340.
.NOTES
Author: Adam Cook
@codaamok
codaamok / Invoke-CM1902LabBuild.ps1
Last active February 17, 2020 13:16
Install AutomatedLab and start CM-1902 lab build
function Invoke-CM1902LabBuild {
if (-not(Get-Package -Name "AutomatedLab" -ProviderName "msi" -MinimumVersion "5.17.0")) {
$Path = "{0}\Downloads\AutomatedLab.msi" -f $HOME
Invoke-WebRequest -Uri "https://github.com/AutomatedLab/AutomatedLab/releases/latest/download/AutomatedLab.msi" -OutFile $Path -ErrorAction "Stop"
Start-Process "msiexec" -ArgumentList @("/i", $Path, "/qb") -Wait -ErrorAction "Stop"
}
try {
$Path = "{0}\Downloads\codaamok-PoSH" -f $HOME
git clone https://github.com/codaamok/PoSH.git $Path
@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' = {
### Keybase proof
I hereby claim:
* I am codaamok on github.
* I am codaamok (https://keybase.io/codaamok) on keybase.
* I have a public key ASAJfgIjA29owfyPLxBNLSM9ssUv-voCVrtVruiP46vWhQo
To claim this, I am signing this object:
@codaamok
codaamok / ConvertTo-Ini.ps1
Created June 3, 2020 21:25
Using StringBuilder class, create a multi line string in typical .ini format from an array of hash tables or ordered dictionaries.
function ConvertTo-Ini {
param (
[Object[]]$Content,
[String]$SectionTitleKeyName
)
begin {
$StringBuilder = [System.Text.StringBuilder]::new()
$SectionCounter = 0
}
process {
@codaamok
codaamok / New-PSSouthamptonVirtualSession.ps1
Created July 12, 2020 16:24
PSSouthampton streaming content
<#
.SYNOPSIS
Create a new properties.json file containing the speaker's name, session title, Twitter handle and local path to their Twitter profile picture. This script also downloads said profile picture. The produced properties.json file is intended to be consumed by index.php within this gist.
.EXAMPLE
PS C:\> .\New-PSSouthamptonVirtualSession.ps1 -SessionTitle "Some session title goes here" -SpeakerName "Adam Cook" -TwitterHandle "codaamok"
Downloads the profile picture of Twitter account @codaamok to "C:\xampp\htdocs\PSSouthampton"
Creates properties.json file with the below object:
@codaamok
codaamok / freedom.to proxy list
Last active December 30, 2020 10:14
A list of domains to bypass the Windows proxy configured by Freedom, for Microsoft / Office 365 services
freedom.to;*.localhost;*.127.0.0.1;*.office.com;*.office365.com;*.office.net;*.onedrive.com;*.sharepoint.com;*.optimizely.com;*.microsoftonline.com;*.production.us.trafficmanager.net;*.microsoft.com;*.live.com;*.oneclient.sfx.ms;*.sharepointonline.com;*.spoprod-a.akamaihd.net;*.prod.msocdn.com;*.svc.ms;*.lync.com;*.broadcast.skype.com;*.skypeforbusiness.com;*.sfbassets.com;*.skypemaprdsitus.trafficmanager.net;*.windows.net;*.msecnd.net;*.aspnetcdn.com;*.live.net;*.aka.ms;*.azure.net;*.windows.com;*.windows.net;*.msedge.net;*.mstea.ms;*.skypeassets.com;*.azureedge.net;*.tenor.com;*.microsoftstream.com;*.assets-yammer.com;*.azureedge.net;*.onenote.com;*.onenote.net;*.aspnetcdn.com;*.optimizely.com;*.msappproxy.net;*.msftidentity.com;*.msidentity.com;*.windowsazure.com;*.microsoftazuread-sso.com;*.microsoftonline-p.net;*.msauth.net;*.msauthimages.net;*.msftauth.net;*.msftauthimages.net;*.phonefactor.net;*.visualstudio.com;*.cloudapp.net;*.staffhub.ms;*.gfx.ms;*.appex.bing.com;*.appex-rf.msn.com;*.getmicrosoftkey
#Requires -Module AutomatedLab
Param (
[Parameter(Mandatory=$true)]
$LabName,
[Parameter(Mandatory=$true)]
$Domain
)
New-LabDefinition -Name $LabName -DefaultVirtualizationEngine HyperV