willwm
7/17/2018 - 11:03 PM

PowerShell Snippets

PowerShell Snippets

# Display a sorted list of all installed UWP applications
Get-AppxPackage | Sort-Object | Foreach { $_.Name }

# Import all (self-signed) certificates in the current folder
@(ls *.cer).ForEach({ Import-Certificate -CertStoreLocation Cert:\CurrentUser\My -FilePath $_; })

# Run 'git-pull-all' command for all children of C:\Dev\
Get-ChildItem C:\Dev\ | foreach { git-pull-all $_ }

# Get all enabled Windows Features, sorted by FeatureName
Get-WindowsOptionalFeature -Online | Where-Object State -eq "Enabled" | Sort-Object -Property "FeatureName" | Foreach { $_.FeatureName }
# https://win32.io/posts/How-To-Find-Text-PowerShell
Get-ChildItem "C:\path\to\folder"  -recurse | Where-Object { (Get-Content $_) -like '*TextToFind*' } | Select-Object { $_.FullName } 

# ...as a function:
function Find-TextInFiles($searchPath, $text) {
  Get-ChildItem $searchPath -recurse | Where-Object { (Get-Content $_) -like '*$text*' } | Select-Object { $_.FullName } 
}