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
$LUP_DEEP = 0x0001 # Queries deep as opposed to just the first level. | |
$LUP_CONTAINERS = 0x0002 # Returns containers only. | |
$LUP_NOCONTAINERS = 0x0004 # Do not return containers. | |
$LUP_NEAREST = 0x0008 # If possible, returns results in the order of distance. The measure of distance is provider specific. | |
$LUP_RETURN_NAME = 0x0010 # Retrieves the name as lpszServiceInstanceName. | |
$LUP_RETURN_TYPE = 0x0020 # Retrieves the type as lpServiceClassId. | |
$LUP_RETURN_VERSION = 0x0040 # Retrieves the version as lpVersion. | |
$LUP_RETURN_COMMENT = 0x0080 # Retrieves the comment as lpszComment. | |
$LUP_RETURN_ADDR = 0x0100 # Retrieves the addresses as lpcsaBuffer. | |
$LUP_RETURN_BLOB = 0x0200 # Retrieves the private data as lpBlob. |
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
#region Profiler | |
class Profiler | |
{ | |
[System.Diagnostics.Stopwatch[]]$StopWatches | |
Profiler([System.Management.Automation.Language.IScriptExtent]$extent) | |
{ | |
$lines = $extent.EndLineNumber | |
$this.StopWatches = [System.Diagnostics.Stopwatch[]]::new($lines) | |
for ($i = 0; $i -lt $lines; $i++) | |
{ |
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
New-Module -Name tt -ScriptBlock { | |
$ErrorActionPreference="stop" | |
function t1 { | |
[CmdletBinding()] | |
param() | |
try { | |
"trying" | |
Get-Content c:\TheFileWhichDoesNotExist.txt | |
"Yiiihaaaa" | |
} catch { |
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
class ScriptBlockInjectorVisitor : System.Management.Automation.Language.ICustomAstVisitor | |
{ | |
[scriptblock]$BeforeScriptBlock = $null | |
[scriptblock]$ReplacementScriptBlock = $null | |
[scriptblock]$AfterScriptBlock = $null | |
[int]$Index | |
[System.Object] VisitElement([object]$element) { | |
if ($element -eq $null) { | |
return $null | |
} |
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
#################################### BEGIN ############################################## | |
$Title = "My Doc" | |
$lab = { | |
########## Module | |
###### Task - Set an alias | |
#### Description | |
## Set an alias using Set-Alias and test it. | |
### Example: |
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
$ModuleName = "MyTestModule" | |
$userModulePath = $env:PSModulePath.Split(";") -like "*\$env:USERNAME\*" | |
New-Item -Path "$userModulePath\$ModuleName" -ItemType Directory -Force | Out-Null | |
{function Get-Zero{0}function Get-One{1}}|Set-Content "$userModulePath\$ModuleName\$ModuleName.psm1" | |
New-ModuleManifest -Path "$userModulePath\$ModuleName\$ModuleName.psd1" -RootModule "$ModuleName.psm1" -FunctionsToExport "Get-Zero" | |
Get-Module -ListAvailable -Name $ModuleName | |
Get-Zero |
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
Write-Host "Done Name State HasData" | |
$global:js = [System.Collections.ArrayList]::new() | |
for($i=0;$i -lt 10;$i++){ | |
$j = Start-Job {"JOB" + $using:i;Start-Sleep -Milliseconds (Get-Random -Maximum 3000 -Minimum 0) } -Name "MyJob-$i" | |
$j | Add-Member -Name CursorTop -MemberType NoteProperty -Value ([console]::CursorTop) -Force | |
[void]$js.Add($j) | |
Write-Host "x " -ForegroundColor Red -NoNewline | |
Write-Host ("{0} {1} {2}" -f $j.Name,$j.State,$j.HasMoreData) | |
} | |
[console]::CursorVisible = $false |
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
# DropDown Data | |
$office = @{ | |
'HQ' = 'Ground floor','1st floor','2nd floor','3rd floor' | |
'Garage' = 'Shop floor','Office' | |
'Sales office' = 'Ground floor','1st floor' | |
} | |
# Load assemblies | |
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | |
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") |
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
$Name = "MSFT-Office 365 Enterprise E1" | |
$groupSearcher = [adsisearcher]"(samaccountname=$Name)" | |
$group = $groupSearcher.FindOne() | |
$memberSearch = [adsisearcher]::new($group.GetDirectoryEntry(),"(&(objectClass=user)(objectCategory=Person))",[string[]]'samaccountname','base') | |
$memberSearch.AttributeScopeQuery = "member"; | |
foreach($member in $memberSearch.FindAll()) | |
{ | |
$member.Properties['samaccountname'] | |
} |
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 Get-CertificateChain { | |
param( | |
[string]$server=$(throw "Mandatory parameter -Server is missing."), | |
[int]$port=$(throw "Mandatory parameter -Port is missing."), | |
[switch]$ToBase64 | |
) | |
$code=@" | |
using System; | |
using System.Collections; | |
using System.Net; |
OlderNewer