This file contains 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.Collections.Generic; | |
using System.Management.Automation.Language; | |
public class ScriptExtent : IScriptExtent | |
{ | |
private readonly IScriptPosition _start; | |
private readonly IScriptPosition _end; |
This file contains 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.Collections; | |
using System.Collections.Generic; | |
using System.Management.Automation; | |
using System.Reflection; | |
using System.Text; | |
namespace RobPsUtils | |
{ | |
public abstract class PSObjectSerializer |
This file contains 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 CSharpPlayground | |
{ | |
public static class GetProcArgv | |
{ | |
private const int CTL_KERN = 1; | |
private const int KERN_ARGMAX = 8; | |
private const int KERN_PROCARGS2 = 49; |
This file contains 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
param( | |
[int]$Iterations = 100, | |
[switch]$Clean | |
) | |
$ErrorActionPreference = 'Stop' | |
function Exec | |
{ | |
param( |
This file contains 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.Collections.Generic; | |
using System.Management.Automation.Language; | |
using Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic; | |
namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules | |
{ | |
public class AvoidConstrainedLanguageErrors : ConfigurableRule | |
{ | |
public override IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName) |
This file contains 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
$badBytes = [byte[]]@(0xC3, 0x80) | |
$utf8Str = [System.Text.Encoding]::UTF8.GetString($badBytes) | |
$bytes = [System.Text.Encoding]::ASCII.GetBytes('Write-Output "') + [byte[]]@(0xC3, 0x80) + [byte[]]@(0x22) | |
$path = Join-Path ([System.IO.Path]::GetTempPath()) 'encodingtest.ps1' | |
try | |
{ |
This file contains 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 Enable-WritingToPath { | |
param([string]$Path) | |
# This is not a problem on Windows | |
if (-not ($IsMacOS -or $IsLinux)) { | |
return | |
} | |
Write-Verbose "Setting permissions on path: $Path" |
This file contains 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.Collections.Generic; | |
using System.IO; | |
using System.Security.Cryptography; | |
using System.Text; | |
using Newtonsoft.Json; | |
using Newtonsoft.Json.Linq; | |
namespace Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol | |
{ |
This file contains 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
param( | |
[ValidateNotNullOrEmpty()] | |
[string]$KeyFileName, | |
[ValidateNotNullOrEmpty()] | |
[string]$KeyFileDir = $null | |
) | |
# Test if the given Windows Identity is the Built-in Administrator | |
function Test-IsAdministrator | |
{ |
This file contains 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
private static RunspacePool CreatePssaRunspacePool() | |
{ | |
// Use public but unfriendly APIs to import a PSScriptAnalyzer module with the needed minimum version | |
var pssaModuleSpec = new ModuleSpecification(new Hashtable() | |
{ | |
{ "ModuleName", PSSA_MODULE_NAME }, | |
{ "ModuleVersion", s_pssaMinimumVersion } | |
}); |