This file contains 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 Convert-StringToValidateSetParameterCase { | |
Param ( | |
[Parameter(Mandatory)] | |
[System.Management.Automation.InvocationInfo]$InvocationInfo | |
, | |
[Parameter(Mandatory)] | |
[string]$ParameterName | |
, | |
[Parameter(Mandatory)] | |
[AllowEmptyString()] |
This file contains 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-AllCombos { | |
[CmdletBinding()] | |
[OutputType("System.Collections.Generic.List[System.Object]")] | |
Param ( | |
[Parameter(Mandatory)] | |
[AllowEmptyCollection()] | |
#[System.Collections.Generic.List[System.Object]]$arr | |
[System.Collections.Generic.List[System.Object]]$arr | |
) | |
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop |
This file contains 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
// Specify a value for `testCidr` (must be a valid CIDR; so if just looking for a specific IPv4 IP, append /32 on the end). | |
// Run this and you'll see all IP Groups which contain CIDRs or IPs which overlap in any way with the given value. | |
resourcecontainers | where type == "microsoft.resources/subscriptions" | limit 1 // this is a hack to give us a single row | |
| project testCidr = "123.123.123.123/32" // update this value to the CIDR you're interested in | |
| extend testCidrSplit = array_concat(split(split(testCidr, '/')[0],'.'), split(split(testCidr, '/')[1],'x')) | |
| extend testCidrFirstIp = toint(testCidrSplit[0]) * 16777216 + toint(testCidrSplit[1]) * 65536 + toint(testCidrSplit[2]) * 256 + toint(testCidrSplit[3]) | |
| extend testCidrLastIp = testCidrFirstIp + pow(2,32-testCidrSplit[4])-1 | |
| extend joinhack = 1 | |
| join kind = inner |
This file contains 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 | |
Used to help migrate R53 zones by converting the JSON obtained by | |
extracting all record sets from a zone to the JSON required to upload | |
these recordsets to another zone. | |
.DESCRIPTION | |
Covers those tasks described in step 4 of [Migrating an AWS Zone](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zones-migrating.html#hosted-zones-migrating-create-file) | |
i.e. to convert the output of `aws route53 list-resource-record-sets --hosted-zone-id <hosted-zone-id>` | |
... to the input of `aws route53 change-resource-record-sets --hosted-zone-id id-of-new-hosted-zone --change-batch file://path-to-file-that-contains-records` |
This file contains 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 Copy-FtpItem { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory, ValueFromPipeline)] | |
[string[]]$Path | |
, | |
[Parameter(Mandatory)] | |
[string]$FtpHost |
This file contains 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
variable "demoIpv4Cidr" { | |
type = string | |
default = "10.0.0.1/16" # try "10.0.0.0/16" for a valid value or "10.0.0.x/16" for an invalidly formatted cidr | |
validation { | |
condition = ( | |
can(cidrhost(var.demoIpv4Cidr, 0)) && | |
try(cidrhost(var.demoIpv4Cidr, 0), null) == split("/", var.demoIpv4Cidr)[0] | |
) | |
# the above could be simplified to: |
This file contains 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 ConvertTo-RootDomain { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory)] | |
[string]$Domain | |
) | |
if ($null -eq $Global:CachedPublicDomainSuffixList) { | |
$publicDomainSuffixList = Invoke-WebRequest -Method GET -Uri 'https://publicsuffix.org/list/public_suffix_list.dat' -ContentType 'text/plain' -ErrorAction Stop | |
$tempSet = [System.Collections.Generic.HashSet[string]]::new() | |
foreach ($suffix in @($publicDomainSuffixList.Content -split '\s*[\r\n]+')) { |
This file contains 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
# some function we want available in our parallel runspace | |
function Get-DummyItem { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory)] | |
[string]$Name | |
) | |
$myIp = Invoke-WebRequest -Method Get -Uri 'https://api.my-ip.io/ip' | |
"[$Name] was processed by [$myIp]" |
This file contains 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 Repair-AzureDevOpsConnection { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory)] | |
[string]$AzureDevOpsPAT # bad practice to pass secrests as strings, but this is a quick and dirty | |
, | |
[Parameter(Mandatory)] | |
[string]$Org | |
, | |
[Parameter(Mandatory)] |
This file contains 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
Login-AzAccount # opens browser for interactive login | |
$subscriptions = Get-AzSubscription | | |
Where-Object {$_.State -eq 'Enabled'} | | |
Select-Object -ExpandProperty 'Id' | |
$script = @' | |
$driveInfo = Get-PSDrive -PSProvider FileSystem | Select-Object Root, Description | |
$pageFileDrive = Get-WmiObject Win32_Pagefile | Select-Object -ExpandProperty Drive | |
([PSCustomObject]@{ | |
DriveInfo = ($driveInfo | %{"$($_.Root) = $($_.Description)"}) -join '; ' |
NewerOlder