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
<Configuration> | |
<!-- Add with Update-FormatData -PrependPath --> | |
<ViewDefinitions> | |
<View> | |
<Name>MatchInfo</Name> | |
<ViewSelectedBy> | |
<TypeName>Microsoft.PowerShell.Commands.MatchInfo</TypeName> | |
</ViewSelectedBy> | |
<CustomControl> | |
<CustomEntries> |
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.Linq | |
class StandardDeviation{ | |
hidden [decimal] $Average | |
StandardDeviation([decimal] $average){ | |
$this.Average = $average | |
} |
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
# practice tasks | |
# task1: Get all processes that on your machine where the processname starts with 'po' | |
Get-Process -name po* | |
#task 2: Get all processes where the handlecount > 1000 | |
Get-Process | Where-Object HandleCount -gt 1000 | |
#task 3: How many files are there in %windir%\System32 | |
Get-ChildItem -File -LiteralPath $env:windir/System32 | Measure-Object |
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.Management.Automation | |
function Update-LastWriteTime { | |
[CmdletBinding(DefaultParameterSetName='Path', SupportsShouldProcess)] | |
[OutputType([IO.FileInfo])] | |
[Alias('touch')] | |
param( | |
[Parameter(Mandatory, ParameterSetName="Path", Position=0, ValueFromPipeline, ValueFromPipelineByPropertyName)] | |
[string[]] $Path, | |
[Alias('PSPath')] |
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.0 | |
using namespace System.Management.Automation | |
using Namespace System.Collections | |
using Namespace System.Collections.Generic | |
<# | |
.SYNOPSIS | |
Combine items from the pipeline into a string, optionally adding single or double quotes |
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 | |
class RGCompleter { | |
static [bool] ShouldAdd([string] $completionText, [string] $wordToComplete, [string[]] $previousCommand, [string[]] $multiOpt) { | |
if ($completionText.StartsWith($wordToComplete, [StringComparison]::OrdinalIgnoreCase)){ | |
if ($completionText -in $previousCommand -and $completionText -notin $multiOpt) { | |
return $false | |
} | |
return $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
. C:\Users\Staffan\Documents\WindowsPowerShell\JoinItem.ps1 | |
class OptionHelp { | |
[string] $Short | |
[string] $Long | |
[string] $Arg | |
[string] $Help | |
} |
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.Management.Automation | |
using namespace System.IO | |
using namespace System.Collections.Generic | |
class PEHeaders { | |
[String] $Path | |
[CoffHeader] $Coffheader | |
[PEHeader] $PEHeader | |
[SectionHeader[]] $SectionHeaders | |
[DebugDirectoryEntry[]] $DebugDirectoryEntires |
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.Security.Principal | |
function ConvertFrom-SID { | |
[CmdletBinding()] | |
[OutputType([NTAccount])] | |
param([SecurityIdentifier[]] $SID) | |
$SID.Foreach{$_.Translate([NTAccount])} | |
} |
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 -MemberDefinition @" | |
[DllImport("kernel32.dll", SetLastError=true)] | |
public static extern bool SetConsoleMode(IntPtr hConsoleHandle, int mode); | |
[DllImport("kernel32.dll", SetLastError=true)] | |
public static extern IntPtr GetStdHandle(int handle); | |
[DllImport("kernel32.dll", SetLastError=true)] | |
public static extern bool GetConsoleMode(IntPtr handle, out int mode); |
OlderNewer