Windows Powershell Potpourri


The purpose of this article is to display a set of commonly used Windows Powershell Scripts

To recursively remove a folder that may contain too many folders for Windows to handle
remove-item -path "C:\Program Files\ScienceLogic" -recurse -verbose
Get System Boot Time
systeminfo | find /i "Boot Time"
Get all files in a folder and subfolders
get-childitem -file -path "c:\Temp" -Recurse -Name | Split-path -Leaf
Remove all items in Downloads folders for all users with local profile
ls c:\Users\*\Downloads -Recurse -Directory | REMOVE-ITEM -Recurse
Remove all Items that start with Archive in current Directory
Get-ChildItem | Where-Object Name -Like 'Archive*' | ForEach-Object { Remove-Item -LiteralPath $_.Name}
Import from a CSV with Name header Write Name
Import-csv .\Computers.csv | ForEach-Object { Write-host "$($_.Name)"}
Get Client DNS from Powershell
Pay attention to the InterfaceAlias
This will be used to Set DNS with Set-DNSClientServerAddress
Set DNS quickly through Powershell
Set-DNSClientServerAddress "Ethernet" –ServerAddresses ("","")
Clear Client DNS Cache