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 Remove-ModulePreviousVersion { | |
<# | |
.SYNOPSIS | |
Removes all previous versions of given module. | |
.DESCRIPTION | |
Long description | |
.EXAMPLE | |
PS C:\> $m = 'oh-my-posh' | |
PS C:\> Remove-ModulePreviousVersion -ModuleName $m -Verbose -WhatIf | |
Removes all previous versions of given module oh-mu-posh |
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
# credit Tom Chantler: https://github.com/TomChantler/EditHosts | |
function Remove-RecordFromHosts | |
{ | |
[cmdletbinding()] | |
param( | |
[Parameter(Mandatory = $true, Position = 0)] | |
[string] $Hostname | |
) | |
begin |
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
# credit Tom Chantler: https://github.com/TomChantler/EditHosts | |
function Add-RecordToHosts | |
{ | |
[cmdletbinding()] | |
param ( | |
[Parameter(Mandatory = $true, Position = 0)] | |
[ValidatePattern('^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$')] | |
[string[]] $DesiredIP, | |
[Parameter(Mandatory = $true, Position = 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
# This code parse the audit logs exported from azure devops and saved as file auditlog.json | |
function Parse-AzureDevOpsAuditLogs { | |
[CmdletBinding()] | |
Param( | |
[Parameter(Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
[string] $Path | |
) |
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
# A random session is chosen | |
$AllServices = Get-Service | |
$Body = foreach($Service in $AllServices) { | |
[PSCustomObject]@{ | |
ServiceName = $Service.ServiceName | |
ServiceStatus = $Service.Status | |
Startup = $Service.StartupType | |
Requires = $Services.RequiredServices | |
} |
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
[string]$(deploymentPath) | |
[string]$(FORWARD_PORT) | |
$ErrorActionPreference = 'Stop' | |
echo "starting function" | |
# set runtime location | |
[string] $ArgumentList = "powershell.exe -command ""set-location $(deploymentPath);func start --port $(FORWARD_PORT) --verbose""" | |
Write-Host "Executing:: $ArgumentList" |
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-SQLDatabase | |
{ | |
param( | |
[Parameter(Position = 0, Mandatory = $True, ValueFromPipeline = $True)] [string] $Server, | |
[Parameter(Position = 1, Mandatory = $True)] [string] $Database, | |
[Parameter(Position = 2, Mandatory = $True, ParameterSetName = 'SQLAuth')] [string] $Username, | |
[Parameter(Position = 3, Mandatory = $True, ParameterSetName = 'SQLAuth')] [string] $Password, | |
[Parameter(Position = 2, Mandatory = $True, ParameterSetName = 'WindowsAuth')] [switch] $UseWindowsAuthentication | |
) |
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 json | |
import sys | |
#from pprint import pprint as pretty | |
# read json | |
def read_json(appSettingsFile): | |
with open(appSettingsFile) as data_file: | |
data = json.load(data_file) | |
# pretty(data) | |
return data |
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
### load functions region | |
function Format-Json | |
{ | |
<# | |
.SYNOPSIS | |
Prettifies JSON output. | |
.DESCRIPTION | |
Reformats a JSON string so the output looks better than what ConvertTo-Json outputs. | |
.PARAMETER Json | |
Required: [string] The JSON text to prettify. |
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 | |
Substitutes connection string via json connstring key. | |
.DESCRIPTION | |
Substitutes connection string via json connstring key. | |
.EXAMPLE | |
PS>$files = ('C:\TEMP\git\moneycorp\Screening.Batch\Screening.Batch.Db\appsettings.json','C:\TEMP\git\moneycorp\Screening.Batch\Screening.Batch.Api\appsettings.json').Split(',') | |
PS>foreach($file in $files){ | |
PS> $Transform = @{ | |
PS> Filepath = $file |
NewerOlder