Skip to content

Instantly share code, notes, and snippets.

View Tiberriver256's full-sized avatar
๐Ÿ“š
Still learning

Micah Rairdon Tiberriver256

๐Ÿ“š
Still learning
View GitHub Profile
@Tiberriver256
Tiberriver256 / PowerShellNTFSStaticFileServer.ps1
Last active July 29, 2024 12:16
This script starts a small web server listening on localhost:8080 that will impersonate the authenticated user and serve static content. This means if they do not have NTFS permissions to the file they will get an access denied or a 404 file not found if they do not have NTFS access to list contents of the directory.
function Get-DirectoryContent {
<#
.SYNOPSIS
Function to get directory content
.EXAMPLE
Get-DirectoryContent -Path "C:\" -HeaderName "poshserver.net" -RequestURL "http://poshserver.net" -SubfolderName "/"
@Tiberriver256
Tiberriver256 / LicenseSKUToNameMappingHash.ps1
Last active May 10, 2023 22:04
LicenseSKUToNameMapping HashTable
$LicenseSKUToNameMapping = @{
'SHAREPOINTENTERPRISE_MIDMARKET' = 'SharePoint Online (Plan 1)'
'ESKLESSWOFFPACK_GOV' = 'Microsoft Office 365 (Plan K2) for Government'
'AAD_BASIC' = 'Azure Active Directory Basic'
'AAD_BASIC_AAD_BASIC' = 'Azure AD Basic - Azure Active Directory Basic'
'AAD_BASIC_EDU' = 'Azure Active Directory Basic for EDU'
'AAD_EDU' = 'Azure Active Directory for Education'
'AAD_PREMIUM' = 'Azure Active Directory Premium P1'
'AAD_PREMIUM_AAD_PREMIUM' = 'Azure AD Premium P1 - Azure AD Premium P1'
'AAD_PREMIUM
@Tiberriver256
Tiberriver256 / PSWebServer.psm1
Last active March 6, 2024 03:49
Sample of making a simple webserver in PowerShell. If you have more complex needs checkout Pode (https://github.com/Badgerati/Pode) as a fully fledged PowerShell web server.
Function New-PSWebServer {
<#
.Synopsis
Creates a web server that will invoke PowerShell code based on routes being asked for by the client.
.Description
New-PSWebServer creates a web server. The web server is composed of a schema that defines the client's requests to routes where PowerShell code is executed.
Under the covers, New-PSWebServer uses the HTTPListener .NET class to execute powershell code as requested, retrieves the results and sends data back through the httplistener web server framework.
function new-PowershellWebGUI ($HTMLRaw,$Title,$Runspace) {
[xml]$xaml = @"
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Title="$Title" Height="500" Width="700">
<Grid>
<DockPanel>
<WebBrowser Name="WebBrowser" DockPanel.Dock="Top" Margin="30">
</WebBrowser>
@Tiberriver256
Tiberriver256 / Get-OrgChart.ps1
Created August 21, 2016 03:32
Get-OrgChart
function Get-ADdirectReports
{
PARAM ($SamAccountName)
$AllUsers = @()
$Manager = Get-Aduser -identity $SamAccountName -Properties DistinguishedName,CN,co,city,DisplayName,mail
$DirectReports = Get-ADUser -Filter {Manager -eq $Manager.DistinguishedName} -Properties manager
function Show-HTML ([string]$HTML)
{
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
[xml]$XAML = @'
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="PowerShell HTML GUI" WindowStartupLocation="CenterScreen">
<WebBrowser Name="WebBrowser"></WebBrowser>
Function Show-Diff {
param([String[]]$OldString,[String[]]$NewString)
$WebPage = @"
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
Function Out-JSONView {
[cmdletbinding()]
Param (
[parameter(ValueFromPipeline)]
[psobject]$InbutObject,
[int]$Depth = 2
Function Start-PoshWebGUI ($ScriptBlock)
{
# We create a scriptblock that waits for the server to launch and then opens a web browser control
$UserWindow = {
# Wait-ServerLaunch will continually repeatedly attempt to get a response from the URL before continuing
function Wait-ServerLaunch
{
try {
@Tiberriver256
Tiberriver256 / Get-DNSConfiguration.ps1
Created April 19, 2016 13:33 — forked from dotps1/Get-DNSConfiguration.ps1
Retrieves the DNS Servers from all IPEnabled Network Adapters.
<#
.SYNOPSIS
Retrives DNS Servers from a computer.
.DESCRIPTION
Retrives primary, secondary, tertiery DNS Servers from on online system with Windows Management Instrimentation.
.INPUTS
System.String.
.OUPUTS
System.Management.Automation.PSObject.
.PARAMETER ComputerName