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 | |
| 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 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 Copy-FtpItem { | |
| [CmdletBinding()] | |
| Param ( | |
| [Parameter(Mandatory, ValueFromPipeline)] | |
| [string[]]$Path | |
| , | |
| [Parameter(Mandatory)] | |
| [string]$FtpHost |
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
| 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 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 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 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
| # 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 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 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 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
| 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 '; ' |
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 Compare-ArrayItems { | |
| [CmdletBinding()] | |
| Param ( | |
| [Parameter(Mandatory)] | |
| [PSObject[]]$ReferenceArray | |
| , | |
| [Parameter(Mandatory)] | |
| [PSObject[]]$DifferenceArray | |
| ) | |
| # note: this treats the arrays as sets; i.e. doesn't care what position items are in within an array, or if the same item occurs multiple times |
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 Receive-TcpServerResponse { | |
| [CmdletBinding()] | |
| Param ( | |
| [Parameter(Mandatory = $true)] | |
| [System.IO.StreamReader]$StreamReader | |
| ) | |
| # useful notes on SMTP https://www.rfc-editor.org/rfc/rfc5321.html / http://www.tcpipguide.com/free/t_SMTPRepliesandReplyCodes-3.htm / FTP on https://www.w3.org/Protocols/rfc959/4_FileTransfer.html | |
| $return = [PSCustomObject]@{PSTypeName='TcpResponse';Code=$null;Text=''} # don't need code, but no harm in leaving it (it was here from: ) | |
| $hasMoreData = $true | |
| #Write-Verbose ': Awaiting Server Response' |
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-FilesInDirectory { | |
| [CmdletBinding()] | |
| Param ( | |
| [Parameter(Mandatory)] | |
| [string]$Path | |
| , | |
| [Parameter(Mandatory)] | |
| [string]$SearchPattern | |
| , |