Powershell
Updated: October 29, 2024
Neat things to do in power shell.
Table of Contents
Setup
# oh my posh module
Install-Module -Name Terminal-Icons -Repository PSGallery
Check Disks
SFC/scannow # run on CMD // Logs found at C:\Windows\Logs\CBS\CBS.log
DISM.exe /Online /Cleanup-image /Restorehealth # can run before or after System File Checker
chkdsk c: /f /r # repairs bad drive sectors if detected
# check nvidia driver
nvidia-smi
Commands
cd /NAME/ # change directory
command to type # description of command
color 04 [0-f=Background][0-f=Text]
cls # clear Screen
explorer # open file explorer
cipher /E # encrypts Folder @Dir Loc
cipher /W:%Directory% # cleans Out Plain Text
netsh wlan set hostednetwork mode=allow ssid=HotspotName key=Password # setup Hotspot
netsh wlan start hostednetwork # starts Hosting
netsh wlan stop hostednetwork # stops Hosting
attrib +h +s +r # hide folder @dir loc
attrib -h -s -r # unhide folder
shutdown -i # remote Shutdown [names=IP]
%command% | clip # prints outcome to clibboard
wmic product get name # lists all programs installed
wmic product where “%NAME%” call uninstall /nointeractive # uninstalls Program
doskey /history # list command history
<command> /? # get information about a command
History
Get-History
# save history to a file
Get-Content (Get-PSReadlineOption).HistorySavePath > pwsh_history.txt
Networking
netsh wlan show profiles Shows list of hotspots
netsh wlan show profile %NAME% key=clear key content=pw
# get IP address
nslookup myip.opendns.com resolver1.opendns.com
Recall
Go to Local Group Policy Editor > User > Administrative Templates > Windows Components > Windows AI
Turn on to turn off Recall Snapshots
# Check if Recall is running
Dism /Online /Get-Featureinfo /Featurename:Recall
# Disable Recall
Dism /Online /Disable-Feature /Featurename:Recall
# Enable Recall
Dism /Online /Enable-Feature /Featurename:Recall
Scan for viruses
# updates antivirus signatures
update-mpsignature
# scans for viruses
start-mpscan -scantype fullscan
sfc/scannow
Setup putty while on root, for users
adduser bucky
gpasswd -a bucky sudo # adds bucky to the group sudo.
wsl
# set default wsl version
wsl --set-default-version 2
# list wsl version
wsl -l -v
# list wsl distros
wsl -l -q
# launch a distro
wsl -d nixos
# close the shell, don't type exit for these
wsl -t nixos
# install wsl distro from store
wsl --install -d Ubuntu
# install distro from a zip
wsl --import nixos .\nixos\ .\Downloads\nixos-wsl.tar.gz --version 2
# delete a distro
wsl --unregister nixos