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 Invoke-ScriptBlockWithRetries { | |
[CmdletBinding(DefaultParameterSetName = 'RetryNonTerminatingErrors')] | |
param ( | |
[Parameter(Mandatory = $true, HelpMessage = "The script block to execute.")] | |
[ValidateNotNull()] | |
[scriptblock] $ScriptBlock, | |
[Parameter(Mandatory = $false, HelpMessage = "The maximum number of times to attempt the script block when it returns an error.")] | |
[ValidateRange(1, [int]::MaxValue)] | |
[int] $MaxNumberOfAttempts = 5, |
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
param([string] $PfxFilePath, $Password) | |
# You may provide a [string] or a [SecureString] for the $Password parameter. | |
$absolutePfxFilePath = Resolve-Path -Path $PfxFilePath | |
Write-Output "Importing store certificate '$absolutePfxFilePath'..." | |
Add-Type -AssemblyName System.Security | |
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 | |
$cert.Import($absolutePfxFilePath, $Password, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]"PersistKeySet") |
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 | |
PUT SHORT SCRIPT DESCRIPTION HERE AND ADD ANY ADDITIONAL KEYWORD SECTIONS AS NEEDED (.PARAMETER, .EXAMPLE, ETC.). | |
#> | |
[CmdletBinding()] | |
param ( | |
# PUT PARAMETER DEFINITIONS HERE AND DELETE THIS COMMENT. | |
) | |
process { |
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
public static T InvokeMethodWithRetries<T>(Func<T> method, int maxNumberOfAttempts = 5) | |
{ | |
int numberOfAttempts = 0; | |
while (numberOfAttempts < maxNumberOfAttempts) | |
{ | |
try | |
{ | |
return method.Invoke(); | |
} | |
catch (Exception ex) |
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
:: This script will migrate all of the IIS Applications and Configuration from the local server to the destination server. | |
:: This script needs to be ran from the source server that has the IIS configuration that you want to migrate. | |
:: MsDeploy will often generate a lot of output, so it's best to remote desktop onto the server that you want to migrate, | |
:: rather than running this command via PowerShell Remoting, as it will take a very long time to pipe the output back to | |
:: your local machine. | |
:: The server you are syncing to must also have Web Deploy installed on it. You can download it from: | |
:: http://www.microsoft.com/en-ca/download/details.aspx?id=43717 | |
:: Be sure to do the "Complete" installation, not just the "Typical" so that the Web Deployment Agent Service gets installed. |
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
# This file should only include settings that affect the physical contents of the file, not just how it appears in an editor. | |
# Do not include personal preference presentation settings like a tab's `indent_size` in this file; those should be specified | |
# in a parent .editorconfig file outside of the repository. | |
# v1.7 - Source: https://gist.github.com/deadlydog/bd000162e85c155b243a712c16f7411c | |
# Ensure that personal preference presentation settings can be inherited from parent .editorconfig files. | |
root = false | |
#### Core EditorConfig Options #### |
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
# This code shows how to easily test a Slack webhook from PowerShell. The URL here is a dummy URL. | |
$slackUri = "https://hooks.slack.com/services/T025sdfsdfsdf/B67sdfsdfsdf/khAfsdfsfsfsdfsdfsdf" | |
$body = ConvertTo-Json @{ | |
pretext = "Testing Slack integration" | |
text = "This is just a test to ensure the Slack webhook works and sends messages to the correct Slack channel." | |
color = "#142954" | |
} | |
Invoke-RestMethod -Uri $slackUri -Method Post -Body $body -ContentType 'application/json' |
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
using Caching; | |
using Microsoft.Extensions.Logging; | |
namespace App; | |
public class ExampleUsage | |
{ | |
private readonly ILogger<ExampleUsage> _logger; | |
private readonly StaleMemoryCache _staleMemoryCache; | |
private readonly IAuthService _authService; |
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
Get-Something dslkfjds lkjfdsl jflkdsfljdsalkf dslkf jlkdsjf lkdsj fljds lkf jdsalkf dslkfj dslfj lkdsjf ldskj flkds jflkjds lkf jdslfk jdsalkf jds jflkds jflkdsjflkds flkjdsflk jdslkf lkdsjflkdsj fljds lkf jdslfj sldjf kds flk jdsfl dsf dsljf ds jfhds lf jdsjf dsljflkds jfsjldsj fl jdsflkjdsflkjds dsfadsf dd |
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
# This .editorconfig file should live outside of all repositories (and thus not be committed to source control) in | |
# a parent directory, as it includes personal preference settings, like a tab's `indent_size`. | |
# v1.3 | |
root = true | |
[*] | |
charset = utf-8 | |
end_of_line = crlf | |
indent_style = tab |
NewerOlder