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 | |
, |
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
import com.microsoft.sqlserver.jdbc.*; | |
import java.sql.*; | |
public class DBTest { | |
public static void main(String[] args) { | |
if (args.length != 1) { | |
System.out.println("Please provide a connection string as an argument when calling this method; exactly 1 argument expected; received: " + args.length); | |
return; |
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 Import-IISLog { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory, ValueFromPipeline)] | |
[System.IO.FileInfo]$Path | |
, | |
[Parameter()] | |
[Microsoft.PowerShell.Commands.FileSystemCmdletProviderEncoding]$Encoding = [Microsoft.PowerShell.Commands.FileSystemCmdletProviderEncoding]::Ascii | |
) | |
Begin { |