This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------- | |
# PART 1 | |
#------- | |
# input file | |
$plane=Get-Content "/Users/{username}/Downloads/AdventOfCode_Day5.txt" | |
Function Get-Seat { | |
[cmdletbinding()] | |
param( | |
[Parameter(Mandatory)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[string] $Site = 'https://www.example.com' | |
[string] $ApiKey = '123456' | |
$posts = (Invoke-RestMethod -Uri "$Site/ghost/api/v2/content/posts/?key=$ApiKey").posts.url | |
$posts | Foreach-Object { | |
[PSCustomObject]@{ | |
'Url'=$_ | |
'StatusCode'=(iwr -Uri $_).StatusCode | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
New-UDPage -Name "Home" -Icon home -Content { | |
New-UDRow -Columns { | |
New-UDColumn -Size 6 { | |
New-UDGrid -Title 'IP Addresses' -AutoRefresh -RefreshInterval 3600 -Endpoint { | |
$IPs = nmap -sn 192.168.202.0/24 | grep scan | |
$Results = Foreach ($IP in $IPs) { | |
[PSCustomObject]@{ | |
Hostname = ($IP -split ' ')[4] | |
IP = ($IP -split ' ')[5] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is required if script is not run as admin. It will open up this script as Admin | |
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { | |
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs | |
exit | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Orgs = @('Default', 'YourOrg1', 'YourOrg2') | |
$Result = Foreach ($Org in $Orgs) { | |
$params = @{ | |
Server = "https://kace.example.com" | |
Org = $Org | |
Credential = (Get-Credential) # or supply stored creds in desired manner | |
QueryParameters = "?paging=limit all" | |
} | |
$query = Get-SmaMachineInventory @params |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-OwnedPW { | |
param( | |
[string] $test | |
) | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
$a, $b = (Get-FileHash -A 'SHA1' -I ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($test)))).Hash -split '(?<=^.{5})' | |
(((Invoke-RestMethod "https://api.pwnedpasswords.com/range/$a" -UseB) -split '\r\n' -like "$b*") -split ':')[-1] | | |
Foreach-Object { | |
Write-Host -ForegroundColor Green "This has been publically cracked $_ times according to api.pwnedpasswords.com" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[Parameter(Mandatory = $true)] | |
[string] $Device, | |
[PSCredential] $Credential | |
) | |
$InvokeParams = @{ | |
Computername = $Device | |
ScriptBlock = { Get-WBSummary } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Often, a 32-bit binary needs to call a 64bit binary or registry hive. | |
# Place the following code at the very top of a powershell script to determine if powershell.exe is being invoked as a 32bit process, redirect it to use 64bit, then continue executing whatever follows. | |
# Relaunch in x64 powershell if not already | |
if ($PSHOME -like "*syswow64*") { | |
Write-Output 'Relaunching as x64' | |
& (Join-Path ($PSHOME -replace 'syswow64', 'sysnative') powershell.exe) ` | |
-File $Script:MyInvocation.MyCommand.Path ` | |
@args | |
Exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put programs to remove in this array. Java and Opera are in this example. | |
$remove = @('*Java*', '*Opera*' ) | |
function Get-InstalledApps { | |
param ( | |
[Parameter(ValueFromPipeline=$true)] | |
[string[]]$ComputerName = $env:COMPUTERNAME, | |
[string]$NameRegex = '' | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Servers = Get-ADComputer -Filter {(enabled -eq $True) -and (OperatingSystem -like "*Windows*")} | Select-Object -ExpandProperty Name | |
$OnlineServers = Test-Connection -ComputerName $Servers -AsJob -Count 1 | Wait-Job | Receive-Job | where-object { $_.StatusCode -eq 0} | select -ExpandProperty Address | |
$RemoteScriptBlock = { | |
$SMB1Enabled = Get-SmbServerConfiguration | Select-Object -ExpandProperty EnableSMB1Protocol | |
[pscustomobject]@{ | |
'Computer' = $Env:ComputerName | |
'SMB1 Present' = $SMB1Enabled |