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
| # | |
| # Rough and ready script to clean up trailing spaces from tag names | |
| # Loops through all resources and resource groups under all subscriptions to which you have access. | |
| # If a resource isn't already tagged with the clean (same name with no trailing space) then the clean tag name is given the diry tag's value, and the dirty tag is removed. | |
| # If a resource has both clean and dirty tags, this shows a warning (even if the values are the same... I was lazy / didn't add a check for that) and leaves to the caller to fix manually. | |
| # If a resource doesn't have any dirty tags, it's not affected. | |
| # | |
| Clear-Host | |
| Login-AzAccount # (interactive / opens web browser) |
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 Test-SqlConnection { | |
| [CmdletBinding(DefaultParameterSetName = 'ByConnectionString')] | |
| Param ( | |
| [Parameter(ParameterSetName = 'ByConnectionString', Mandatory)] | |
| [string]$ConnectionString | |
| , | |
| [Parameter(ParameterSetName = 'AuthSqlUser', Mandatory)] | |
| [Parameter(ParameterSetName = 'AuthAdCredentials', Mandatory)] | |
| [Alias('DbInstance')] | |
| [string]$ComputerName |
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 |