Skip to content

Instantly share code, notes, and snippets.

View lfalck's full-sized avatar

Ludvig Falck lfalck

View GitHub Profile
@lfalck
lfalck / RemoveCurlAlias.ps1
Last active April 3, 2023 09:11
Remove the PowerShell alias curl -> Invoke-WebRequest
# This script will add the Remove-Item alias:curl command to an existing PowerShell profile or create one if it does not exist
# If it is run from PowerShell ISE an ISE profile will be created: Microsoft.PowerShellISE_profile.ps1
# Otherwise a regular profile will be created: Microsoft.PowerShell_profile.ps1
$removeCurlAlias = @"
# Remove Alias curl -> Invoke-WebRequest
Remove-Item alias:curl
"@
if (-Not (Test-Path $Profile))
Shortcut to command:
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command "& { Write-Host "Hello"; Write-Host "World"}"
Shortcut to file:
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -NoExit -File %HOMEPATH%\MyScript.ps1
# Script to publish binary modules to Powershell Gallery based on Publish-ToPowerShellGallery.ps1 from https://github.com/mmaitre314/PowerShellGet-Test-Binary-Module
$manifestFilename = Get-ChildItem -Path $PSScriptRoot -Filter *.psd1 | Select-Object -First 1 -ExpandProperty Name
$manifestPath = Join-Path $PSScriptRoot $manifestFilename
$manifestData = Test-ModuleManifest -Path $manifestPath
Write-Host "Module version needs to be incremented before publishing. Current version is $($manifestData.Version)"
Update-ModuleManifest -Path $manifestPath -CmdletsToExport '*' -ModuleVersion (Read-Host "New module version: ")
//Postman pre-request Script which generates a SAS token query string.
const storageSasKey = pm.variables.get("storageSasKey");
const storageAccountName = pm.variables.get("storageAccountName");
const storageSasTokenQueryString = createStorageSASTokenQueryString(storageAccountName, storageSasKey);
pm.variables.set("storageSasTokenQueryString", storageSasTokenQueryString);
/**
Connect-AzureRmAccount
Set-AzureRmKeyVaultAccessPolicy -VaultName 'keyvaultname' -EnabledForTemplateDeployment
$context = New-AzureRmApiManagementContext -resourcegroup 'ContosoResourceGroup' -servicename 'ContosoAPIMService'
Connect-AzureRmAccount
New-AzureRmApiManagementBackend -Context $context -Url 'https://backendurl' -Protocol http -SkipCertificateChainValidation $true
Get-AzureRmApiManagementBackend -Context $context
Remove-AzureRmApiManagementBackend -Context $context -BackendId 9e8e5a6ba56a4607af8e9dc4cc63fd92
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation=$(Build.ArtifactStagingDirectory) /p:Configuration=Release
Add-PSSnapin WDeploySnapin3.0
$packagePath = $env:System_DefaultWorkingDirectory + '\_' + $env:Release_DefinitionName + '\drop\' + $env:Release_DefinitionName + '_BT_WCF.zip'
Restore-WDPackage -Package $packagePath -Parameters @{ "IIS Web Application Name"=$env:WebApplicationName }
// Not empty or whitespace
^\S+$