Skip to content

Instantly share code, notes, and snippets.

View JohanSelmosson's full-sized avatar

Johan Selmosson JohanSelmosson

View GitHub Profile
@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
#WIP in progress as of 2022-01-12
function Start-ExchangeMaintenance {
[CmdletBinding()]
param
(
[parameter(Mandatory = $true)]
[validateNotNullOrEmpty()]
[String]$MaintenanceServer,
#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 = @()
@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",
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 / 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) {
@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 / 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 / get-nordloshcannelloggingevents.ps1
Last active September 5, 2024 09:18
get-nordloshcannelloggingevents.ps1
function Get-NordloSChannelLoggingEvents {
<#
.SYNOPSIS
Extracts Schannel logging events from the Windows Event Log.
.DESCRIPTION
This function retrieves Schannel logging events from either the System or ForwardedEvents log.
It can filter events based on a specified time period and output the results to a CSV file.
.PARAMETER Period
@JohanSelmosson
JohanSelmosson / Get-NordloAzureRoleAssignments.ps1
Last active September 20, 2024 05:53
Get-AzureRoleAssignments
function Get-AzureRoleAssignments {
<#
.SYNOPSIS
Retrieves Azure Role Assignments for specified scopes.
.DESCRIPTION
The Get-AzureRoleAssignments function retrieves Azure Role Assignments for either a specific subscription, a management group, or all accessible subscriptions. It can optionally include group members for assignments made to groups.
.PARAMETER SubscriptionId
Specifies the ID of the subscription to retrieve role assignments from. If not specified, and ManagementGroupId is also not specified, the function will retrieve role assignments from all accessible subscriptions.