Skip to content

Instantly share code, notes, and snippets.

@romero126
romero126 / readme.md
Created August 29, 2023 05:35
ConvertFrom-CidrToIPvNetwork

ConvertFrom-CidrToIPvNetwork -vlsm "10.202.84.0/25" ConvertFrom-CidrToIPvNetwork -vlsm "2001:489a:a0d::/64"

function Monitor-Object {
param(
[Parameter()]
[Alias('Begin')]
[ScriptBlock]$BeginBlock = {
param(
[Parameter(Mandatory)]
[object] $InputObject
)
return $InputObject
@romero126
romero126 / Import-ModuleManually
Created July 19, 2023 18:20
Import-Module Manually
function Import-ModuleManually {
param(
[Parameter(Mandatory=$true)]
[string]$Module,
[Parameter(Mandatory=$false)]
[switch]$Force
)
$moduleExists = Get-Module -Name $Module -All
function Invoke-ForEachObjectWithProgress {
[CmdletBinding()]
[Alias("ForEachWP")]
param(
[Parameter(Mandatory, ValueFromPipeline)]
[object] $InputObject,
[Parameter()]
[string] $Activity = "Processing items",
@romero126
romero126 / Code.ps1
Created September 30, 2022 01:28
NamedPipelines
function New-NamedPipeServer {
param(
[Parameter(Mandatory)]
[string] $PipeName,
[Parameter(Mandatory)]
[scriptblock] $ScriptBlock
)
Start-Job -Name $PipeName -ScriptBlock {
@romero126
romero126 / text.md
Created August 6, 2022 09:46
Scratch
[
{
"S": [
{
"N": "G0",
"T": 1,
"DN": "D0"
},
{
"N": "G1",
@romero126
romero126 / Connect-DeviceAuthorization.ps1
Created May 9, 2021 21:39
Connect-DeviceAuthorization
function Connect-DeviceAuthorization {
[CmdletBinding()]
param(
[Parameter(
HelpMessage = "Specify an Application ClientID defaults to the ClientID for 'AzureAD'"
)]
[string] $ClientID = '1b730954-1685-4b74-9bfd-dac224a7b894',
[Parameter(
#Import-Module "$PSScriptRoot\..\Module\WindowsPresentationFramework" -Force
. "$PSScriptRoot\WindowsPresentationFramework.ps1"
#Region ThreadSafe
# Bind Variables
[WindowsPresentationFrameworkThreadSafe()]
[PSObject] $Variable = "Herro World from Proxy Scope"
[WindowsPresentationFrameworkThreadSafe()]
$Sync = [hashtable]::Synchronized(@{})
@romero126
romero126 / ConstrainedVariableInterpolation
Last active May 9, 2021 22:44
ExpandStringVisitor: Context locked String Interpolation using AstVisitor
class ConstrainedVariableInterpolation : System.Management.Automation.Language.AstVisitor {
hidden [Hashtable] $Property
[System.Collections.Generic.List[PSCustomObject]] $Result
hidden [System.Management.Automation.Language.Ast] $Ast
[System.Management.Automation.Language.AstVisitAction] CheckForPostAction([System.Management.Automation.Language.Ast] $ast, [System.Management.Automation.Language.AstVisitAction] $action)
{
throw 'CheckForPostAction not supported'
}
class ConstrainedVariableInterpolation : System.Management.Automation.Language.AstVisitor {
hidden [Hashtable] $Property
[System.Collections.Generic.List[PSCustomObject]] $Result
hidden [System.Management.Automation.Language.Ast] $Ast
[System.Management.Automation.Language.AstVisitAction] CheckForPostAction([System.Management.Automation.Language.Ast] $ast, [System.Management.Automation.Language.AstVisitAction] $action)
{
throw 'CheckForPostAction not supported'
}