Skip to content

Instantly share code, notes, and snippets.

View TheRealNoob's full-sized avatar

TheRealNoob TheRealNoob

View GitHub Profile
## Powershell Version: x.x
Write-host -ForegroundColor Green -BackgroundColor Black ("PowerShell Version: " + (Get-Host | Select-Object -ExpandProperty Version))
## System Uptime: xx:xx:xX
$UpTime = [Management.ManagementDateTimeConverter]::ToDateTime((Get-WmiObject Win32_OperatingSystem).LastBootUpTime)
$UpTime = (Get-Date) - $Uptime
$UpTime = "{0:D2}" -f [int]$UpTime.Days + ':' + "{0:D2}" -f [int]$UpTime.Hours + ':' + "{0:D2}" -f [int]$UpTime.Minutes + ':' + "{0:D2}" -f [int]$UpTime.Seconds
Write-Host -ForegroundColor Green -BackgroundColor Black "System Uptime: $($UpTime)"
"`n"
function Coffee
{
Write-Host @'
( (
) )
........
| |]
\ /
`----'
$ports = @{
'File shares/RPC' = '139' ;
'File shares' = '445' ;
'RDP' = '3389';
#'Zenworks' = '1761';
}
foreach ($service in $ports.Keys) {
stuff
}
# Scan for open ports
$ports = @{
'File shares/RPC' = '139' ;
'File shares' = '445' ;
'RDP' = '3389';
#'Zenworks' = '1761';
}
foreach ($service in $ports.Keys) {
Function Get-SystemInfo {
<#
.SYNOPSIS
Get Complete details of local system info
.DESCRIPTION
This function uses WMI class to query local machine for system info.
Output is saved to [array] $data
.EXAMPLE
Get-SystemInfo
System [PSCustomObject]
Hardware [hashtable]
BIOSManufacturer
BIOSName
BIOSVersion
RAMPhysical
RAMTotal
RAMUsed
RAMFree
CPUManufacturer
<#
TODO
SUGGESTIONS:
------------------------------------------
alternatives to WMI: CIM (maxfrost), async (jrich)
FIREWALL:
------------------------------------------
$list = import-csv file.csv
Foreach ($person in $list) {
Send-MailMessage -To $person."E-Mail Address" -Subject "Password expires in $person."Password expires in" days" `
-From * `
-Body "$person."Display Name", your password is due to expire in $person."Password expires in" days. Please change it or die."
}
<#
CSV CONTENT
Display Name,SAM Account Name,Password Last Set,Password Expiry Date,E-mail Address,Password expires in
FakeNam1,FakeUsername1,Blah1,123,[email protected],4 day(s)
FakeNam2,FakeUsername2,Blah2,456,[email protected],3 day(s)
#>
#Variables
$ComputerList = "$HOME\Desktop\computerlist.txt"
$SaveDestination = "$HOME\Desktop"
#Setup
$ErrorActionPreference = "SilentlyContinue"
#Script
foreach ($ComputerName in (Get-Content $ComputerList))
{