Skip to content

Instantly share code, notes, and snippets.

View SteveL-MSFT's full-sized avatar

Steve Lee SteveL-MSFT

View GitHub Profile
function Get-SuspiciousElement {
param ( [scriptblock]$sb, [switch]$InPlace )
$susProp = $sb.ast.gettype().GetProperty("HasSuspiciousContent", [reflection.bindingflags]"NonPublic,Instance")
$suspiciousContent = ""
$sb.Ast.FindAll({$true}, $true) | %{
      if ( $susProp.GetValue($_) ) {
            $suspiciousContent = $_.Extent.Text
      }
$ExecutionContext.InvokeCommand.CommandNotFoundAction =
{
param(
[string]
$commandName,
[System.Management.Automation.CommandLookupEventArgs]
$eventArgs
)
param(
[string]$include = "*.resx"
)
$filesToExclude = @(
'FlashExtractStrings.resx'
'*Xaml*.resx'
'TabCompletionStrings.resx'
'*UICultureResources.resx'
'ComputerResources.resx'
write-progress -id 1 -Activity "Getting all modules"
$modules = find-module -Repository PSGallery
$moduleNames = $modules.Name
$fz = [System.Reflection.Assembly]::GetAssembly([System.Management.Automation.PowerShell]).GetType("System.Management.Automation.FuzzyMatcher")
$fzmatch = $fz.GetMethod("GetDamerauLevenshteinDistance")
$fzmatches = @{}
$i = 1
foreach ($module in $moduleNames) {
write-progress -id 1 -Activity "Searching" -Status "$module" -PercentComplete ([int32]([double]$i / [double]($moduleNames.Count) * 100))
[cmdletbinding()]
param(
[Parameter(Mandatory=$true,Position=0)]
[string]$command,
[Parameter(Position=1)]
[string]$class
)
if ($command -eq 'path') {
using System;
using System.Management.Automation;
using System.Text;
namespace ClipboardReverse
{
[Cmdlet(VerbsCommon.Get,"ClipboardReverse")]
[OutputType(typeof(string))]
public class ClipboardReverse : PSCmdlet
{
]
hello world
]633;Completions?
param(
[Parameter(ValueFromPipeline=$true)]
[ValueType]
$profileEvent
)
begin {
$profileEvents = [System.Collections.Generic.List[object]]::new()
}
param(
[Parameter(ValueFromPipeline)]
[string]$json
)
$obj = ConvertFrom-Json -InputObject $json -Depth 100 -AsHashtable
$location = "/"
function Test-Location ($path) {