Skip to content

Instantly share code, notes, and snippets.

@theaquamarine
theaquamarine / cmcontentlocations.ps1
Created May 30, 2020 19:21
CM Content Locations
# Get-ApplicationDeploymentTypes | Get-ApplicationDeploymentTypeInstallContent | Get-ContentCacheLocation
# Get-CCMApplication | Get-ApplicationDeploymentTypes | Get-ApplicationDeploymentTypeInstallContent | Get-ContentCacheLocation
function Get-ContentCacheLocation {
param (
[Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)]
[Alias('PackageID', 'PKG_PackageID')]
[string]$contentId
)
process {
Get-CimInstance -Namespace root/ccm/SoftMgmtAgent -Query "SELECT Location FROM CacheInfoEx WHERE ContentID='$contentId'" | Select-Object -ExpandProperty Location
function Invoke-NativeCommand {
<#
.SYNOPSIS
Invoke a native command (.exe) as a new process.
.DESCRIPTION
Invoke-NativeCommand executes an arbitrary executable as a new process. Both the standard
and error output streams are redirected.
Error out is written as a single non-terminating error. ErrorAction can be used to raise
function Measure-ChildItem {
<#
.SYNOPSIS
Recursively measures the size of a directory.
.DESCRIPTION
Recursively measures the size of a directory.
Measure-ChildItem uses win32 functions, returning a minimal amount of information to gain speed. Once started, the operation cannot be interrupted by using Control and C. The more items present in a directory structure the longer this command will take.
This command supports paths longer than 260 characters.
@SteveL-MSFT
SteveL-MSFT / profile.ps1
Last active March 11, 2024 01:21
PowerShell Prompt
#Requires -Version 7
# Version 1.2.13
# check if newer version
$gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e"
$latestVersionFile = [System.IO.Path]::Combine("$HOME",'.latest_profile_version')
$versionRegEx = "# Version (?<version>\d+\.\d+\.\d+)"
if ([System.IO.File]::Exists($latestVersionFile)) {
# (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
@indented-automation
indented-automation / Get-InstalledSoftware.ps1
Last active August 11, 2023 22:35
Get-InstalledSoftware
function Get-InstalledSoftware {
<#
.SYNOPSIS
Get all installed from the Uninstall keys in the registry.
.DESCRIPTION
Read a list of installed software from each Uninstall key.
This function provides an alternative to using Win32_Product.
.EXAMPLE
Get-InstalledSoftware
@ipbastola
ipbastola / clean-up-boot-partition-ubuntu.md
Last active May 2, 2024 01:27
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule