- Get the Plaster Module from Plaster Github
- Get the latest version of the VS Code Powershell Extension.
- Create a zip file of the contents of the NewModuleTemplate folder in the Examples.
- Set the TemplatePath variable in the ps1 file below to the path of the zip.
- Set a Destination directory in the ps1 below.
- Either place the code below in the Microsoft.VSCode_profile.ps1 profile or highlight and hit f8 to temporarily load it for testing.
- Start the Command Palette by pressing f1 or ctrl+shift+P
- type 'addi' and hit enter (Short for Show additional commands for powershell modules)
- Enter the information prompted.
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-WildCardsWorks | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[Parameter(Mandatory=$true, | |
Position=0, | |
ParameterSetName="Path", | |
ValueFromPipeline=$true, | |
ValueFromPipelineByPropertyName=$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
# Is there a reason why one might use Example 1 over Example 2 if only using a single command? | |
## Example 1 | |
New-Module -Name SomeModule -Function "SomeFunction" -ScriptBlock { Function SomeFunction { Write-Host "Invoking SomeFunction with $params"} } | Import-Module | |
## Example 2 | |
Function SomeFunction { Write-Host "Invoking SomeFunction with $params"} | |
## Example Usage | |
Describe "Invoke-Something" { |
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
Register-EditorCommand ` | |
-Name "MyModule.OpenPowerShellConsole" ` | |
-DisplayName "Open PowerShell Console" ` | |
-SuppressOutput ` | |
-ScriptBlock { | |
$Arch = (Get-WmiObject -Class 'Win32_Processor').AddressWidth | |
If ($Arch -eq '64') | |
{ | |
#launch powershell via sysantive here |
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
add-type -TypeDefinition @" | |
using System; | |
public static class KeyboardEventTestUtil { | |
public static string keybd_event(byte bVk, byte bScan, UInt32 dwFlags, System.UIntPtr dwExtraInfo) { | |
return string.Format("{0}:{1}:{2}:{3}", bVk,bScan,dwFlags,dwExtraInfo); | |
} | |
} | |
"@ | |
describe "t" { |
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 EnsureServiceStarted { | |
param($Name) | |
Start-Service -name $name | |
$service = Get-Service -Name $name | |
$service.Status -eq [ServiceProcess.ServiceControllerStatus]::Running | |
} | |
Describe "Ensure service is started" { | |
It "Started service returns true" { | |
mock start-service {} |
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
Register-EditorCommand ` | |
-Name "Helpers.EditVSCodeProfile" ` | |
-DisplayName "Edit VS Code Profile" ` | |
-SuppressOutput ` | |
-ScriptBlock { | |
param([Microsoft.PowerShell.EditorServices.Extensions.EditorContext]$context) | |
$psEditor.Workspace.OpenFile("$env:USERPROFILE\OneDrive\PowerShell\Profiles\Microsoft.VSCode_profile.ps1") | |
} | |
Register-EditorCommand ` |
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-Module Emojis | |
function Invoke-EmojiSelection | |
{ | |
[Cmdletbinding()] | |
param | |
( | |
[Microsoft.PowerShell.EditorServices.Extensions.EditorContext]$context | |
) | |
$EmojiText = $context.CurrentFile.GetText($context.SelectedRange) |
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 Invoke-PlasterToolkit | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[Microsoft.PowerShell.EditorServices.Extensions.EditorContext]$context, | |
[Parameter(Mandatory=$true)] | |
[string]$Name = (Read-Host 'Please type Toolkit Name') | |
) |
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
<?xml version="1.0" encoding="utf-8"?> | |
<plasterManifest version='0.1.0'> | |
<metadata> | |
<id>Unique-Template-Pkg-Name</id> | |
<!-- For display by UI's in a menu list --> | |
<title>New Toolkit</title> | |
<!-- For display by UI's in hover help --> | |
<description>Plaster template for creating the files for a PSAppDeploy Toolkit.</description> | |
<version>0.1.0</version> | |
<tags>Toolkit, Build</tags> |