https://medium.com/faun/cleaning-up-a-terraform-state-file-the-right-way-ab509f6e47f3
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 New-SelfSignedCertPfx { | |
[CmdletBinding(DefaultParameterSetName = 'PasswordAsSecureString')] | |
Param ( | |
[Parameter()] | |
[string[]]$SanList = @('localhost', '127.0.0.1') | |
, | |
[Parameter(ParameterSetName = 'PasswordAsSecureString')] | |
[SecureString]$ExportPassword = [System.Security.SecureString]::new() | |
, | |
# note: using the secure string option is recommended... but tbh most real world cases where you'd use this script you're just looking for something quick and easy |
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-CommentedListFile { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory)] | |
[ValidateScript({(Test-Path -Path $_) -or (&{throw "Path does not exist: '$_'"})})] | |
[string]$Path | |
, | |
[Parameter()] | |
[string]$Encoding = 'UTF8' | |
, |
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-AtlassianScimUsers { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory)] | |
[string]$DirectoryId | |
, | |
[Parameter(Mandatory)] | |
[string]$Token | |
) | |
$startIndex = 1 |
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
-- note: each SQL should be run on its own, then its outputs run, before moving on. | |
-- this is a hacky solution, so just for those quick fix scenarios | |
-- rename existing tables to include an underscore on the end | |
SELECT format ('ALTER TABLE %I.%I RENAME TO %I;', table_schema, table_name, table_name || '_') | |
table_schema, table_name) | |
FROM information_schema.tables | |
where table_schema = 'cam' | |
-- remove any constraints on our table |
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
# hackaround for https://support.google.com/drive/thread/35629075?hl=en | |
# Warnings: | |
# I've not put much sanity wraping around this solution as I just needed a quick fix... there are some risks / caveats / room for improvement | |
# The save method will overwrite existing files with the same name / directory without prompting. Adding a check before saving is trivial / you could add Force, ShouldProcess, NoClobber, etc options as needed. | |
# You can't use the `NewNameMask = '{0}{3}{1}{2}'` (i.e. overwrite the source file), as we keep the file handle of the source open until after the resized image is changed. If that's a need, it's fairly simple to correct; I've just not needed the extra effort | |
Function Convert-ImageSize { | |
[CmdletBinding()] | |
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
# Thanks to Torek for the git command | |
# https://stackoverflow.com/questions/64607795/query-git-index-for-chmod-values-on-windows/64617017#64617017 | |
# https://git-scm.com/docs/git-ls-files | |
function Test-IsExecutable { | |
[CmdletBinding()] | |
Param ( | |
# Side note: Not only should Path point to a file/files within a git repo | |
# but also you should call this command from within that same repo | |
[Parameter(Mandatory = $true, ValueFromPipeline = $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
{ | |
"recommendations": [ | |
"redhat.vscode-yaml" | |
] | |
} |
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
pushd C:\inetpub\logs\LogFiles\W3SVC1 | |
[Regex]$regex = '^(?<date>[\d-]+)\s(?<time>[\d\:]+)\s(?<ServerIP>[\d\.]+)\s(?<method>\S+)\s(?<path>\S+)\s(?<querystring>\S+)\s(?<port>\d+)\s(?<username>\S+)\s(?<clientIP>[\d\.]+)\s(?<browser>\S+)\s(?<fulluri>\S+)\s(?<HttpStatus>\d+)\s(?<a>\d+)\s(?<b>\d+)\s(?<c>\d+)$' | |
cat 'u_ex201015.log' | ?{$_ -like '2020-10-15 07*'} | %{ | |
if ($_ -match $regex) { | |
([PSCustomObject]$Matches) | |
} else { | |
throw "Unexpected line format: '$_'" | |
} | |
} | ft time, ClientIP, username, httpstatus, port, path, querystring -AutoSize | |
popd |
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
[CmdletBinding()] | |
Param() | |
$noProcessors = (Get-WmiObject -class 'Win32_Processor' -Namespace 'root\cimv2').NumberOfLogicalProcessors | |
if ($noProcessors -gt 1) { | |
$maxAffinity = [Math]::Pow(2, $noProcessors) - 1 # i.e. this signfies that all processors are assigned to a process | |
$procsPerUser = [Math]::Ceiling($noProcessors / 3) # i.e. allow users to use 1/3rd the available processors (rounded up) | |
while ($true) { | |