This file contains hidden or 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-ComputerSession { | |
[CmdletBinding()] | |
param( | |
# The computer name to get the current sessions from. Use an empty string for local machine. | |
[Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] | |
[AllowEmptyString()] | |
[String] | |
$ComputerName, | |
# Flattens the output |
This file contains hidden or 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
using namespace System | |
using namespace System.Linq | |
using namespace System.Collections | |
using namespace System.Collections.Generic | |
using namespace System.Management.Automation | |
using namespace System.Management.Automation.Language | |
using namespace System.Reflection | |
# Hey person reading this! Don't do this, alright? You'll have a bad time. ty |
This file contains hidden or 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
<# | |
.SYNOPSIS | |
Windows PowerShell SSH Server Subsystem Shim. | |
.DESCRIPTION | |
Used as a basic wrapper for Windows PowerShell that allows it to be used as a target for SSH based remoting sessions. | |
This allows a PowerShell client to target a Windows host through SSH without having PowerShell 7 installed. | |
.NOTES | |
This is experimental and used as a POC. |
This file contains hidden or 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
class SplatClass : System.Collections.IEnumerable { | |
SplatClass() {} | |
[System.Collections.IEnumerator] GetEnumerator() { | |
# This can be any hashtable stored or derived from the class. This is | |
# just an example | |
$params = @{ | |
Path = '/tmp' | |
} | |
This file contains hidden or 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
Add-Type -Namespace LmAccess -Name Native -MemberDefinition @' | |
[DllImport("Netapi32.dll", CharSet = CharSet.Unicode, EntryPoint = "NetAddServiceAccount")] | |
private static extern int NativeNetAddServiceAccount( | |
IntPtr ServerName, | |
string AccountName, | |
IntPtr Password, | |
AddServiceFlags Flags); | |
/// <summary>Add a sMSA or gMSA to the current host.</summary> | |
/// <param name="accountName">The name of the MSA to install.</param> |

This file contains hidden or 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
. $PSScriptRoot\Start-ProcessEx.ps1 | |
Add-Type -Namespace Runas -Name NativeMethods -UsingNamespace @( | |
'Microsoft.Win32.SafeHandles', | |
'System.ComponentModel', | |
'System.Security.Principal' | |
) -MemberDefinition @' | |
[DllImport("Advapi32.dll", EntryPoint = "DuplicateTokenEx", SetLastError = true)] | |
private static extern bool NativeDuplicateTokenEx( | |
SafeHandle hExistingToken, |
This file contains hidden or 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
<# Check installation compliance #> | |
$Installed = Get-WmiObject -Class Win32Reg_AddRemovePrograms | Where-Object { $_.DisplayName -eq "Sentinel Agent" } | |
If ( -Not $Installed ) { | |
# Sentinel Agent not installed/missing. | |
Return $false | |
} Else { | |
Return $true | |
} |
This file contains hidden or 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
# Copyright: (c) 2021, Jordan Borean (@jborean93) <[email protected]> | |
# MIT License (see LICENSE or https://opensource.org/licenses/MIT) | |
class EncodingTransformAttribute : Management.Automation.ArgumentTransformationAttribute { | |
[object] Transform([Management.Automation.EngineIntrinsics]$engineIntrinsics, [object]$InputData) { | |
$outputData = switch ($InputData) { | |
{ $_ -is [Text.Encoding] } { $_ } | |
{ $_ -is [string] } { | |
switch ($_) { |
This file contains hidden or 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
using namespace System.Management.Automation | |
using namespace System.Management.Automation.Language | |
if ($host.Name -eq 'ConsoleHost') | |
{ | |
Import-Module PSReadLine | |
} | |
#Import-Module PSColors | |
#Import-Module posh-git | |
Import-Module -Name Terminal-Icons |