Skip to content

Instantly share code, notes, and snippets.

@Slusho
Slusho / get-diskusage.ps1
Created May 23, 2019 13:36
Reports logical disk status and graph of disk usage
# Run this script to see connected hard disk status with nifty bar graph!
Begin {
function Get-BarGraph($Percent){
# Max width of graph
$Width = 20
Write-Host '['-NoNewline
# Loop that animates the bar, also scales the percentage so bar does not take up too much space
While($tick++ -le $Percent/100*$Width-1){
if ($tick -le $Width / 1.7) {
Write-Host "$([char]0x25A0)" -NoNewline -ForegroundColor Green
@Slusho
Slusho / Get-ConnectedComputers.ps1
Last active January 3, 2018 21:10
Scans subnet IP range for computers and displays WMI information for each.
# Pings all ipaddresses in given subnet ip range
# Neatly shows IP address, hostname, manufacturer, and model according to WMI
Write-Host 'Enter desired subnet without last octet. Example xxx.xxx.xxx.'
$subNet = Read-Host
$ipFrom = Read-Host 'Last octet range FROM '
$ipTo = Read-Host 'Last octet range TO '
function testRange ($from, $to){
if($from -gt $to){
Write-Host 'Invalid IP range!'-ForegroundColor Red
@Slusho
Slusho / dc-build.ps1
Last active December 23, 2017 16:41
Create dc
<# Notes:
Goal - Create a domain controller and populate with OUs, Groups, and Users.
This script must be run after prepDomainController.
Disclaimer - This example code is provided without copyright and AS IS. It is free for you to use and modify.
Credit to Greg Shields
#>
configuration BuildDomainController
@Slusho
Slusho / dc-prep.ps1
Last active September 30, 2018 08:55
prep domain controller
<# Notes:
Goal - Prepare the local machine by installing needed PowerShell Gallery modules.
Disclaimer - This example code is provided without copyright and AS IS. It is free for you to use and modify.
Credit to Greg Shields
#>
Get-PackageSource -Name PSGallery | Set-PackageSource -Trusted -Force -ForceBootstrap
@Slusho
Slusho / wmic_csprod.txt
Created December 19, 2017 18:42
wmic csproduct
#show info of THIS computer
wmic csproduct
#show info of a REMOTE computer, start a PSSession
Enter-PsSession [computerName]
#show only one of the values from a given column IE "Name"
wmic csproduct get name
@Slusho
Slusho / get-desc
Created November 28, 2017 16:32
Get computer description from AD
$DomainName = 'LDAP://OU=Test Computers,DC=Contoso,DC=Com'
$Root = New-Object DirectoryServices.DirectoryEntry $DomainName
$objSearcher = New-Object DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $Root
$objSearcher.SearchScope = "SubTree"
$objSearcher.Filter = "(objectCategory=computer)"
$colResults = $objSearcher.FindAll()
foreach ($objResult in $colResults)