# Managing Azure Functions via PowerShell Cmdlets
# Prerequisites:
# - PowerShell Core 6 or greater --> https://github.com/PowerShell/PowerShell/releases
# - Core Tools --> https://github.com/Azure/azure-functions-core-tools#installing
# - Az.Functions preview module --> https://www.powershellgallery.com/packages/Az.Functions/0.0.2-preview
# Install Azure Functions PowerShell core module
Install-Module -Name Az.Functions -AllowPrerelease
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 Update-CodePSExePath { | |
| $version=$PSVersionTable.PSVersion.Major | |
| if($version -eq 5) { | |
| $powerShellExePath = (get-command powershell.exe).Source | |
| } else { | |
| $powerShellExePath = (get-command pwsh.exe).Source | |
| } | |
| $settingsFile = "$env:APPDATA\Code\User\settings.json" |
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 ConvertTo-Base64KMSEncryptedString { | |
| [CmdletBinding()] | |
| param ( | |
| [Parameter( | |
| Mandatory = $true, | |
| ValueFromPipeline = $true | |
| )] | |
| [String[]] | |
| $String, |
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
| #requires -version 5.0 | |
| Function ConvertTo-Markdown { | |
| <# | |
| .Synopsis | |
| Convert pipeline output to a markdown document. | |
| .Description | |
| This command is designed to accept pipelined output and create a markdown document. The pipeline output will formatted as a text block. You can optionally define a title, content to appear before the output and content to appear after the output. | |
| The command does not create a text file. You need to pipe results from this command to a cmdlet like Out-File or Set-Content. See examples. | |
| .Parameter Title |
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 ConvertTo-Object { | |
| param( | |
| [Parameter(Mandatory=$true,ValueFromPipeline=$true)] | |
| [AllowEmptyString()] | |
| [string[]]$InputString, | |
| [Parameter(Mandatory=$true,ValueFromRemainingArguments=$true)] | |
| [string[]]$Pattern | |
| ) |
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
| #Requires -Version 7 | |
| # Version 1.2.13 | |
| # check if newer version | |
| $gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e" | |
| $latestVersionFile = [System.IO.Path]::Combine("$HOME",'.latest_profile_version') | |
| $versionRegEx = "# Version (?<version>\d+\.\d+\.\d+)" | |
| if ([System.IO.File]::Exists($latestVersionFile)) { |
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
| Get-Command # Retrieves a list of all the commands available to PowerShell | |
| # (native binaries in $env:PATH + cmdlets / functions from PowerShell modules) | |
| Get-Command -Module Microsoft* # Retrieves a list of all the PowerShell commands exported from modules named Microsoft* | |
| Get-Command -Name *item # Retrieves a list of all commands (native binaries + PowerShell commands) ending in "item" | |
| Get-Help # Get all help topics | |
| Get-Help -Name about_Variables # Get help for a specific about_* topic (aka. man page) | |
| Get-Help -Name Get-Command # Get help for a specific PowerShell function | |
| Get-Help -Name Get-Command -Parameter Module # Get help for a specific parameter on a specific command |
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 ConvertTo-PascalCase | |
| { | |
| [OutputType('System.String')] | |
| param( | |
| [Parameter(Position=0)] | |
| [string] $Value | |
| ) | |
| # https://devblogs.microsoft.com/oldnewthing/20190909-00/?p=102844 | |
| return [regex]::replace($Value.ToLower(), '(^|_)(.)', { $args[0].Groups[2].Value.ToUpper()}) |
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
| #requires -module Indented.StubCommand | |
| function Enable-AutoMockRecord ([Switch]$Append) { | |
| $env:AUTOMOCK_RECORD = $true | |
| if ($Append) {$env:AUTOMOCK_APPEND = $true} | |
| } | |
| function Disable-AutoMockRecord { | |
| Remove-Item env:AUTOMOCK_RECORD -ErrorAction SilentlyContinue | |
| Remove-Item env:AUTOMOCK_APPEND -ErrorAction SilentlyContinue | |
| } |