Skip to content

Instantly share code, notes, and snippets.

View pandiculator's full-sized avatar

Matt Bloomfield pandiculator

View GitHub Profile
@pandiculator
pandiculator / 2018-15-10-psorg.txt
Last active October 15, 2020 12:03
PowerShell.org Forum Response
$driveLetters = Get-Volume | Select -ExpandProperty driveLetter
foreach ($driveLetter in $driveLetters) {
Get-CimInstance CIM_LogicalDiskBasedOnPartition |
Where-Object {$_.Dependent -like "*DeviceID = `"$driveLetter`:`"*"} |
Select @{l='DriveLetter';e={$driveLetter}},@{l='Index';e={$_.Antecedent -match "Disk #[\d]+" |
ForEach-Object {$matches[0]}}}
}
$myString = 'Hint: abcdefghijklmnopqrstuvwxyz'
$myString -match 'Hint: (?<hint>.{0,20})'
$matches.hint
$tables = Get-Content c:\tables.txt
$tables = $tables -replace '<table>\s*<\/table>','foo'
Write-Output $tables
$list = @"
1 Partridge in a pear tree
2 Turtle Doves
3 French Hens
4 Calling Birds
5 Golden Rings
6 Geese a laying
7 Swans a swimming
8 Maids a milking
9 Ladies dancing
#Author: Matt Bloomfield
#Date: 2015-11-03
#First attempt at some basic obfuscation..
'87!114!105!116!101!45!72!111!115!116!32!39!74!117!115!116!32!65!110!111!1'+
'16!104!101!114!32!80!111!119!101!114!83!104!101!108!108!32!69!110!116!104'+
'!117!115!105!97!115!116!44!39' -split '!' | %{$s += -join [char][byte]$_};
iex $s
while ($true){
($computer = Read-Host 'Enter a computer name or ctrl + c to quit'),
(($os = gwmi Win32_OperatingSystem -co $computer),($bios = gwmi Win32_bios -co $computer) | Out-Null),
(New-Object -t PSObject | Add-Member -m NoteProperty -na PSComputerName -va $os.PSComputerName -pa |
Add-Member -m NoteProperty -na ServicePackMajorVersion -va $os.ServicePackMajorVersion -pa |
Add-Member -m NoteProperty -na Version -va $os.Version -pa |
Add-Member -m NoteProperty -na BIOSSerial -va $bios.SerialNumber -pa | ft -a)}