Skip to content

Instantly share code, notes, and snippets.

View JohanSelmosson's full-sized avatar

Johan Selmosson JohanSelmosson

View GitHub Profile
@JohanSelmosson
JohanSelmosson / Test-Portreachable.ps1
Created October 23, 2023 08:55
Test-PortReachable
function Test-PortReachable {
<#
.SYNOPSIS
Tests if different tcp ports are reachable, a few builtin scenarios are included
.DESCRIPTION
This tool checks if one or more ports are reachable on one or more hosts. It can also check if RPC is open and it will display
which RPC Service is available on that port.
.EXAMPLE
Test-PortReachable -Scenario WebServer -Target "www.gp.se", "www.svt.se", "www.boras.se", "www.aftonbladet.se", "www.existerarinte.se"
Connects to the ports included in the scenario "WebServer" and displays the results.
@JohanSelmosson
JohanSelmosson / sendfilesthroughclipboard.ps1
Last active August 22, 2023 11:42
Send files through Clipboard
#Credit: https://gist.github.com/ethzero/47f657ca635752b5bdb45f99eae40182
function Send-Base64EncodedfileThroughClipboard {
[CmdletBinding()]
param (
# Path to file to encode
[Parameter(Mandatory = $true,
Position = 0,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
@JohanSelmosson
JohanSelmosson / uninstall.ps1
Last active December 6, 2022 11:30
Uninstaller for MSI-packages
function Get-InstalledSoftware {
[CmdletBinding()]
param (
)
$InstalledSoftware = Get-ChildItem "HKLM:\software\WOW6432Node\Microsoft\windows\CurrentVersion\Uninstall" | ForEach-Object { Get-ItemProperty $_.PSPath }
$InstalledSoftware += Get-ChildItem "HKLM:\software\Microsoft\windows\CurrentVersion\Uninstall" | ForEach-Object { Get-ItemProperty $_.PSPath }
foreach ($Software in $InstalledSoftware) {
function GetFileAccessEvents {
$events = Get-WinEvent -FilterHashtable @{
LogName = 'ForwardedEvents'
Id = 4663
StartTime = (Get-Date).AddHours(-24)
}
$AccessTypes = @{
[int]4416 = 'ReadData_ListDirectory'
[int]4417 = 'WriteData_AddFile'
@JohanSelmosson
JohanSelmosson / getfolderpermissions.ps1
Last active April 5, 2022 12:08
View Permissions on a folder structure
function GetFolderPermissionInfo {
[CmdletBinding()]
param (
[Parameter()]
[string]
$Path = $(get-location).ProviderPath,
[switch]
$ExportCsv,
[string]
$CSVPath="ACLReport-$(get-date -Format "yyyy-MM-dd_HHmm").csv",
#Källa https://www.bvanleeuwen.nl/faq/?p=1182
#Modifierat för att ta med info om failover status på scope-nivå
import-module DHCPServer
#Get all Authorized DCs from AD configuration
$DHCPs = Get-DhcpServerInDC | Where-Object {$_.DnsName -eq 'sa2netsrv01.prod.pk.local'}
$filename = "c:\nordlo\DHCPScopes_DNS_$(get-date -Uformat "%Y%m%d-%H%M%S").csv"
$Report = @()
#WIP in progress as of 2022-01-12
function Start-ExchangeMaintenance {
[CmdletBinding()]
param
(
[parameter(Mandatory = $true)]
[validateNotNullOrEmpty()]
[String]$MaintenanceServer,
@JohanSelmosson
JohanSelmosson / ReportPendingCertRequests.ps1
Last active January 10, 2022 15:40
Report new Pending Certificate Requests by email
$processedrequestspath = "c:\nordlo\pki\processedrequests.txt"
$smtpserver= 'smtp.domain.local'
$fromaddress= 'noreply@domain.local'
$recipient = 'servicedesk@domain.local'
$KBArticle = 'KBXXXXXXXX'
#[System.Net.ServicePointManager]::SecurityProtocol = 'TLS12'
#install-module pspki