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
using namespace System.Collections.Generic | |
using namespace System.Management.Automation | |
using namespace System.Security.AccessControl | |
using namespace Microsoft.Win32 | |
function Get-InstalledSoftware { | |
[CmdletBinding()] | |
param( | |
[Parameter(ValueFromPipeline)] | |
[ValidateNotNullOrEmpty()] |
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
# Syntax: | |
# ?? -If $true -Then { 'yep' } -Else { 'nah' } | |
# ?? -If $true { 'yep' } : { 'nah' } | |
# ?? -If $true { 'yep' } else { 'nah' } | |
# ?? -If $true { 'yep' } { 'nah' } | |
# | |
# $true | ?? -Then { 'yep' } -Else { 'nah' } | |
# $true | ?? { 'yep' } : { 'nah' } | |
# $true | ?? { 'yep' } else { 'nah' } | |
# $true | ?? { 'yep' } { 'nah' } |
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 Enter-PSSessionWithEdit { | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory)] | |
[ValidateNotNullOrEmpty()] | |
[string] $ComputerName | |
) | |
end { | |
$enterEventName = 'RemoteSessionEditor.Enter' | |
if (-not $Host.Runspace.Events.GetEventSubscribers($enterEventName)) { |
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
PSReadLine | |
https://github.com/PowerShell/vscode-powershell/issues/535 | |
https://github.com/PowerShell/vscode-powershell/issues/569 | |
https://github.com/PowerShell/vscode-powershell/issues/1027 | |
https://github.com/PowerShell/vscode-powershell/issues/815 | |
https://github.com/PowerShell/vscode-powershell/issues/785 | |
https://github.com/PowerShell/vscode-powershell/issues/550 | |
https://github.com/PowerShell/vscode-powershell/issues/873 | |
https://github.com/PowerShell/vscode-powershell/issues/998 | |
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
using System; | |
using System.Runtime.InteropServices; | |
namespace Microsoft.PowerShell.Internal | |
{ | |
internal class PlatformUnix | |
{ | |
// termios | |
private const int STDIN_FILENO = 0; // File descriptor for Standard Input. | |
private const int NCCS = 64; // Size of the array c_cc for control characters. |
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 Get-ActiveTranscriptPath { | |
[CmdletBinding()] | |
param() | |
end { | |
$flags = [System.Reflection.BindingFlags]'Instance, NonPublic' | |
$transcriptionData = $Host.Runspace.GetType(). | |
GetProperty('TranscriptionData', $flags). | |
GetValue($Host.Runspace) | |
$transcripts = $transcriptionData.GetType(). |
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 New-PowerShellApp { | |
[CmdletBinding()] | |
param([string]$FilePath, [string]$Script) | |
end { | |
$Script = $Script -replace '"', '""' | |
Add-Type -OutputType WindowsApplication -OutputAssembly $FilePath -TypeDefinition @" | |
using System.Management.Automation; | |
namespace SilentPowerShell |
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
$typeDefinition = @' | |
using System; | |
using System.Management.Automation; | |
using System.Reflection; | |
namespace PSStateTree.Commands | |
{ | |
[OutputType(typeof(StateTreeInfo))] | |
[Cmdlet(VerbsCommon.Show, "PSStateTree")] | |
public class ShowPSStateTreeCommand : PSCmdlet |
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.1 -Module @{ModuleName = 'PSReadline'; RequiredVersion=1.2} | |
function Invoke-CommandPalette { | |
param( | |
[System.Nullable[System.ConsoleKeyInfo]] $key, | |
[object] $arg | |
) | |
end { | |
# Save the current buffer, cursor position, selection range and selection command count to | |
# be restored after the command is found. |
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 should be included in SQL server if you have it installed, but I don't on this machine. | |
$package = Find-Package Microsoft.SqlServer.TransactSql.ScriptDom -Source https://www.nuget.org/api/v2 | |
$package | Save-Package -Path $PWD | |
$fileBaseName = $package.Name + '.' + $package.Version | |
Rename-Item "$fileBaseName.nupkg" "$fileBaseName.zip" | |
Expand-Archive "$fileBaseName.zip" | |
Add-Type -Path $fileBaseName\lib\net40\Microsoft.SqlServer.TransactSql.ScriptDom.dll | |
# Example from https://docs.microsoft.com/en-us/sql/t-sql/queries/select-examples-transact-sql | |
$tSqlSample = @' |