Skip to content

Instantly share code, notes, and snippets.

while (x == y)
{
something();
somethingelse();
}
while (x == y)`r`n{`r`n`tsomething();`r`n`tsomethingelse();`r`n} }
@gerane
gerane / PSReadline_config.ps1
Created March 1, 2017 16:54 — forked from rkeithhill/PSReadLine_config.ps1
PSReadline configuration updated for PSReadline v1.1
# Need to explicitly import PSReadLine in a number of cases: Windows versions < 10 and
# x86 consoles that aren't loading PSReadLine.
# Source: https://gist.github.com/rkeithhill/3103994447fd307b68be#file-psreadline_config-ps1
# Other hosts (ISE, ConEmu) don't always work as well with PSReadline.
if ($host.Name -ne 'ConsoleHost') { return }
# PSReadline hasn't been auto-imported, try to manually import it
if (!(Get-Module PSReadline -ErrorAction SilentlyContinue)) {
if (!$IsLinux -and !$IsOSX -and ([IntPtr]::Size -eq 4) -and !(Get-Module -ListAvailable PSReadline)) {
{
"version": "0.1.0",
"command": "${env.windir}\\sysnative\\windowspowershell\\v1.0\\PowerShell.exe",
"isShellCommand": true,
"showOutput": "always",
"args": [
"-NoProfile", "-ExecutionPolicy", "Bypass"
],
"tasks": [
{
@gerane
gerane / tasks.json
Last active March 13, 2017 16:10
Watcher Tasks
{
"version": "0.1.0",
"command": "${env.windir}\\sysnative\\windowspowershell\\v1.0\\PowerShell.exe",
"isShellCommand": true,
"showOutput": "always",
"args": [
"-NoProfile", "-ExecutionPolicy", "Bypass"
],
"tasks": [
{
@gerane
gerane / tasks.json
Created March 17, 2017 14:53
Code Coverage VSCode Task
{
"version": "0.1.0",
"windows": {
"command": "${env.windir}\\sysnative\\windowspowershell\\v1.0\\PowerShell.exe"
},
"linux": {
"command": "/usr/bin/powershell"
},
"osx": {
"command": "/usr/local/bin/powershell"
@gerane
gerane / Issue.md
Last active April 5, 2017 13:28
When

When executing the profile selection Editor Command and typing "profile.ps1" you have to double the letters because the first is sent to the console and the second is sent to the Prompt for Choice.

Fitst.log

Fitst.log is after typing "pprroofiillee..ppss11" I had deleted one of the "f" so that it wouldn't try to execute a profile.ps1 or soemthing like that. The log is after hitting enter the first time, which attempts to execute the "proile.ps1" that was sent to the console.

Second.log

Second.log is after hitting enter a second time, this time the Editor Command choice is executed

Register-EditorCommand `
-Name "Demo.Editors" `
-DisplayName "Editors Demo" `
-SuppressOutput `
-ScriptBlock {
param([Microsoft.PowerShell.EditorServices.Extensions.EditorContext]$context)
$SelectedText = $Context.CurrentFile.GetText($context.SelectedRange)
@gerane
gerane / Struct.ps1
Created May 8, 2017 10:57 — forked from proxb/Struct.ps1
Using PowerShell and Reflection to dynamically build a Struct with Constructors and Methods
#region Module Builder
$Domain = [AppDomain]::CurrentDomain
$DynAssembly = New-Object System.Reflection.AssemblyName(([guid]::NewGuid().ToString()))
$AssemblyBuilder = $Domain.DefineDynamicAssembly($DynAssembly, [System.Reflection.Emit.AssemblyBuilderAccess]::Run) # Only run in memory
$ModuleBuilder = $AssemblyBuilder.DefineDynamicModule(([guid]::NewGuid().ToString()), $False)
#endregion Module Builder
#region STRUCTs
#Order of creating these Structs is important
#region MyStruct
$Attributes = 'AutoLayout, AnsiClass, Class, Public, SequentialLayout, Sealed, BeforeFieldInit'
if (((Test-Path -Path $Global:SettingsDirectory\DATSettings.xml) -eq $true) -and ($Global:DATSettingsXML.Settings.DownloadSettings.DeploymentPlatform -eq 'MDT'))
{
$ProgressListBox.ForeColor = "Black"
Write-CMLogEntry -Value "======== Detecting Deployment Platform $(Get-Date) ========" -Severity 1
Write-CMLogEntry -Value "======== Deployment Platform: MDT - Skipping SCCM Validation ========" -Severity 1
}
elseif (((Test-Path -Path $Global:SettingsDirectory\DATSettings.xml) -eq $true) -and (! [string]::IsNullOrEmpty($Global:DATSettingsXML.Settings.SiteSettings.Server)))
{
$SiteServer = [string]$SiteServerInput.Text
$ProgressListBox.ForeColor = "Black"