Skip to content

Instantly share code, notes, and snippets.

@finchd
Last active September 10, 2024 03:48
Show Gist options
  • Save finchd/fb29cdc3187d56eb15c74037394bdaa7 to your computer and use it in GitHub Desktop.
Save finchd/fb29cdc3187d56eb15c74037394bdaa7 to your computer and use it in GitHub Desktop.
The apps I install with chocolatey, etc
# use jessfraz boxstarter config +/- the below
## multipass VMs:
## multipass list
## multipass find (not a search, just what images are published
### multipass launch -c 4 -d 30G -m 16G -n cloud-init-test-2004-2021-07-09 --cloud-init .\multipass-primary-cloud-init.yml 20.04
## Powershell tips:
# powershell version
echo $PSVersionTable.PSVersion
# pipe truncated output to `| format-table -AutoSize`
## do it right, `script -c 'time bash thing.sh' thing-$(date -I).log'` equivalent:
# Measure-Command { thing | tee-object -filepath thing-$(date -I).log } | out-file -append -filepath thing-$(date -I).log
## My First PS Function, referece: https://docs.microsoft.com/en-us/powershell/scripting/learn/ps101/09-functions?view=powershell-7.1
### see script.ps1
## aliases
# Note: `alias.exe` exists in DOS already
# get-alias
# Set-Alias -Name loc -Value Get-Location -Option ReadOnly -Description 'Displays the current directory name'
## can only alias ps command names, program names, and function names, No Arguments!, can pass PS command Options though.
## write all the ones you made by to your profile
# export-alias -append -As Script -Scope Local -Path my-ps-profile.ps1
# windows-specific config files
echo $profile.CurrentUserAllHosts
#C:\Users\<user>\Documents\WindowsPowerShell\profile.ps1 ##windows built-in
#C:\Users\<user>\Documents\PowerShell\profile.ps1 ## PS 7 Core
echo $profile.CurrentUserCurrentHost
#C:\Users\<user>\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
echo $profile.AllUsersAllHosts
#C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
## profile contents
```
$profile.ps1 = @'
### Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
### posh-git, as installed by chocolatey
Import-Module "C:\tools\poshgit\*\src\posh-git.psd1"
### git 2-line prompt
$GitPromptSettings.DefaultPromptSuffix = "`n$('> ' * ($nestedPromptLevel + 1))"
'@
```
## the '`n' is the newline in GitPromptSettings
# (un)security policy for scripts
set-executionpolicy -executionpolicy unrestricted
#see all commands for a module
get-command -module PackageManagement
#update modules first
#modules and packages differ, PackageManagement is both, PowerShellGet is both, better to update the modules then?
update-module -Verbose -WhatIf
#upgrade powershellget & probably packagemanagement, installs to $pshome\Modules
#this install is separate from what a new version of WMF (including new powershell) would have, so may be bad?
install-packageprovider powershellget -verbose -force
#always allow PSGallery - it is the main repo for powershellget
set-packagesource -name PSGallery -trusted
> get-package -providername PowerShellGet
#manual install chocolatey, instead? Isn't this terribly out of date?
install-packageprovider -name Chocolatey -verbose
set-packagesource -name chocolatey -trusted
#get chocolatey to update itself
install-package -Name chocolatey -Source chocolatey
#packages installed by 'choco' do not get listed under:
> get-package -providername chocolatey
#remember to update the help (manpages)
update-help
## end Powershell tips
## disable the Microsoft account prompts after updates?
# or at least disable the "ah ha, caught you logging into edge with an ms acct, now tying the windows user to it"
# https://answers.microsoft.com/en-us/windows/forum/all/how-can-i-completely-disable-microsoft-sign-in-in/c75d6a67-13d9-484d-85eb-45a0a1e573d5
# New-ItemProperty -Path HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name NoConnectedUser -PropertyType DWord -Value 3
# swiftonsecurity's sysmon config https://github.com/SwiftOnSecurity/sysmon-config/
sysmon.exe -accepteula -i https://raw.githubusercontent.com/SwiftOnSecurity/sysmon-config/master/sysmonconfig-export.xml
#plus:
# <NetworkConnect onmatch="exclude">
# <!--COMMENT: finchd custom rules, exclude noisy network apps -->
# <Image condition="image">C:\ProgramData\ZeroTier\One\zerotier-one_x64.exe</Image> <!-- ZeroTier One SDN runs from ProgramData -->
# <Image condition="image">C:\Users\dfinch\.odrive\bin\6484\odriveapp.exe</Image><!-- odrive sync -->
#evtx tracing?
## install PSWindowsUpdate
#no 'update-package' exists, so instead let things get overwritten:
install-package -name PSWindowsUpdate -ProviderName PowerShellGet -force -AllowClobber
# pswindowsupdate in chocolatey is really old, so do force it to use the PSGallery one.
## PSWindowsUpdate usage:
get-wulist -verbose -whatif -showpresearchcriteria
#get-windowsupdate -verbose -whatif <-windowsupdate|-microsoftupdate>
#get-windowsupdate -verbose <> -acceptall
## NeoVim config C:\Users\<user>\AppData\Local\nvim\init.vim
## nvim-qt gui settings in ginit.vim
#get C:\Users\<user>\AppData\Local\nvim\autoload\plug.vim
md ~/AppData/Local/nvim/bundle/
$uri = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
(New-Object Net.WebClient).DownloadFile(
$uri,
$ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(
"~\AppData\Local\nvim\bundle\plug.vim"
)
)
# run :PlugInstall from vim-plug
# https://jdhao.github.io/2018/11/15/neovim_configuration_windows/
# https://jdhao.github.io/2019/01/17/nvim_qt_settings_on_windows/
# https://jdhao.github.io/2018/12/24/centos_nvim_install_use_guide_en/
#vim is difficult to set up on windows - ~/.vim/ vs. ~/vimfiles/, etc
# but the init.vim from nvim works fine:
```
call plug#begin('~/.vim/plugged')
" below are some vim plugin for demonstration purpose
Plug 'joshdick/onedark.vim'
Plug 'iCyMind/NeoSolarized'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
call plug#end()
" https://jdhao.github.io/2018/11/15/neovim_configuration_windows/
" remember to call :plugInstall when editting the above
" I actually like slate more than the 2 colorschemes above
colorscheme slate
" line numbers
set number
" assuming vim-airline and vim-airline-themes
let g:airline_theme='simple'
" only nvim-qt changes below
" nvim-qt reassigned shift-insert away from the OS paste.
inoremap <silent> <S-Insert> <C-R>+
```
#atom config
## apm list --installed --bare > apm-packages.list
$apm-packages.list = @'
ansible-snippets@0.2.0
busy-signal@2.0.1
editorconfig@2.5.0
intentions@1.1.5
language-ansible@0.2.2
language-viml@1.2.0
linter@2.3.1
linter-ui-default@1.8.0
ssh-config@0.14.0
'@
## apm install --packages-file apm-packages.list
#android #
C:\Android\android-sdk\tools\bin\sdkmanager.bat --list
C:\Android\android-sdk\tools\bin\sdkmanager.bat "extras;google;usb_driver"
#Install chocolatey PS #boxstarter installs chocolatey too
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
# chocolatey issue:
#override the checksum stuff with --checksumtype=sha256 --checksum "thing"
#something I have installed provides sha256 sums in the file explorer right-click menu
## chocolatey packages
# install/upgrade openssh first, then "all", b/c you can't pass package params from "all"
#https://github.com/DarwinJS/ChocoPackages/blob/master/openssh/readme.md
choco install -y openssh -params "/SSHServerFeature"
choco install -y 7zip bluescreenview boxstarter etcher fastcopy irfanview inconsolata sysinternals vlc # standard tools & inconsolata font
Cmder mobaxterm #terminals
atom neovim notepadplusplus vscode chocolatey-vscode.extension vscode-settingssync #text editors #vscode-settingssync to private gist
aria2 awscli git curl grep bind-toolsonly# cli tools
ditto launchy listary #workflow improvement
odrive zerotier-one # online services
github-desktop
nitroreader.install
postman
prometheus
android-sdk
qbittorrent
handbrake
cemu dolphin project64
cpu-z fraps
obs-studio
zeal #offline browser for docs
Everything #instant search for all files
wiztree #replace windirstat
baretail logfusion #gui log tail, lnav is linux/mac/wsl only
choco install -y calibre --version 3.46.0 #haven't moved to 4.2.x
choco install -y keepassx --version 2.0.2 #2.0.3 locks up
# choco list explanations:
# mobaxterm
# cmder windows console (cmd/pshell have terrible copy/paste, ui)
# postman REST client
# inconsolata font
# bluescreenview - crashdump viewer
# handbrake - video ripper
# atom - detailed setup above
# neovim - detailed setup above
# android-sdk mostly for usb drivers
# playnite - game multi-library viewer
# moonlight - streaming client
# retroarch?
# itunes? Do I need it any more?
#emu:
# cemu?
# dolphin - GameCube, Wii
# project64 - N64
# odrive
# zerotier-one
# fraps fps monitor
#not: autoupdating (to change to D: drive)
# twitch https://updates.twitchapp.net/windows/installer/TwitchSetup.exe
# discord
# steam
# itch.io
# gog-galaxy
# epic games launcher (fortnite)
# battle.net blizzard launcher (overwatch) https://www.blizzard.com/en-us/apps/battle.net/desktop
#not: local installers:
# brave
# franz
# firefox beta
# easybcd?
## not: not available on choco:
# cemu - Wii U - failed chocolatey install - skipped
# yuzu - NSwitch (Alpha)
# citra - N3DS
# desmume - NDS
# vba-m
# project64 - N64 - failed chocolatey install
# dosbox
##not: desktop only:
# asus 1070 driver+gputweak
# paid synergy
## end choco list
## end chocolatey packages
# firefox extensions
## sign in to firefox sync
## sign in to shaarli w/ zerotier vpn up
## sign in to toggl/todoist/lastpass (only lastpass actually stays logged in?)
## stylus/stylish styles: github wide, github gist wide
# chrome/brave extensions
# Dark Reader
# DuckDuckGo Privacy Essentials ?
# Google Docs Offline (chrome)
# Lastpass
# Mercury Reader or use Distilled Content mode
# Shiny Shaarli
# Refined AWS Console
# Refined GitHub
# Shiny Shaarli
# stylus
## stylus/stylish styles: github wide, github gist wide
# uBlock Origin (Chrome only)
#prometheus windows
#set to start on boot
nssm.exe set prometheus-service Start SERVICE_AUTO_START
# wait for file-writing on reboots
nssm.exe set prometheus-service AppRestartDelay 5000
# stdout logging
md C:\tools\prometheus\logs\
nssm.exe set prometheus-service AppStdout C:\tools\prometheus\logs\std_out.log
nssm.exe set prometheus-service AppStdoutCreationDisposition 2
# stderr logging
md C:\tools\prometheus\logs\
nssm.exe set prometheus-service AppStderr C:\tools\prometheus\logs\std_err.log
nssm.exe set prometheus-service AppStderrCreationDisposition 2
# other from https://groups.google.com/forum/#!topic/prometheus-users/NjtTA7vsVJ8
nssm.exe set prometheus-service AppStopMethodSkip 6
nssm.exe set prometheus-service AppStopMethodConsole 5000
nssm.exe set prometheus-service AppThrottle 5000
nssm.exe set prometheus-service AppRotateFiles 1
nssm.exe set prometheus-service AppRotateOnline 1
nssm.exe set prometheus-service AppRotateSeconds 86400
nssm.exe set prometheus-service AppRotateBytes 10485760
```C:\ProgramData\chocolatey\lib\prometheus\tools\prometheus-2.2.1.windows-amd64\prometheus.yml
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
- 'prometheus.rules.yml'
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9090']
- job_name: 'wmi_exporter'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9182']
```
```prometheus.rules.yml
groups:
- name: wmi_rules
rules:
- record: wmi_logical_disk_read_write_latency_ms_5m
expr: irate(wmi_logical_disk_read_write_latency_seconds_total[5m]) * 1000
```
#prometheus windows metrics
choco install -y prometheus-wmi-exporter.install --params '"/EnabledCollectors:logical_disk,net,os,service,system,textfile,cpu,cs,logon,memory,process /ListenPort:9182"'
# EXTRA_FLAGS="--collector.service.services-where ""Name LIKE 'sql%'"" --collector.process.processes-where=""Name LIKE 'firefox%'"""
# wmi_exporter installs as normal service, no 'nssm'. or:
# nssm install wmi_exporter C:\Program Files\wmi_exporter\wmi_exporter.exe
# edit flags after install with regedit: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wmi_exporter ImagePath
# Set-ItemProperty -Path HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wmi_exporter -Name ImagePath '"C:\Program Files\wmi_exporter\wmi_exporter.exe" --log.format logger:eventlog?name=wmi_exporter --telemetry.addr :9182 --collectors.enabled logical_disk,net,os,service,system,textfile,cpu,cs,logon,memory,process'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment