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
# Server 2025 fails to run Get-AppxPackage and other DISM module commands in | |
# a PSRemoting (psrp) session as it has a dependency on some dll's not present | |
# in the GAC and only in the powershell.exe directory. As PSRP runs through | |
# wsmprovhost.exe, it fails to find those dlls. This hack will manually load | |
# the 4 required dlls into the GAC. This is a hack and should be removed in the | |
# future if MS fix their bug on 2025. | |
Add-Type -AssemblyName "System.EnterpriseServices" | |
$publish = [System.EnterpriseServices.Internal.Publish]::new() |
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-CommandParameter { | |
# .SYNOPSIS | |
# A PowerShell version 2 compatible parameter block parser. | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory = $true, Position = 1, ValueFromPipelineByPropertyName = $true)] | |
[String]$Definition | |
) |
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-CommandParameter { | |
param ( | |
[Parameter(Mandatory = $true)] | |
[String]$Command, | |
[Switch]$GetDefaultValues | |
) | |
$defaultParams = @( | |
[System.Management.Automation.Internal.CommonParameters].GetProperties().Name |
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
#Build Job Name to be unique | |
$JobName = "ExampleJob" | |
$JobNameCount = (get-job | Where-Object Name -like $JobName*).Count | |
$JobName = "$($JobName)_$($JobNameCount)" | |
#Define and Start job | |
$Job = Start-Job -Name $JobName -ScriptBlock { Start-Sleep 60 } | |
#Create Event to clean up job after complete | |
Register-ObjectEvent -InputObject $Job -EventName "StateChanged" -Action { |
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
$ErrorActionPreference = "Stop" | |
$notificationTitle = "Notification: " + [DateTime]::Now.ToShortTimeString() | |
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null | |
$template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText01) | |
#Convert to .NET type for XML manipuration | |
$toastXml = [xml] $template.GetXml() | |
$toastXml.GetElementsByTagName("text").AppendChild($toastXml.CreateTextNode($notificationTitle)) > $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
function Get-NumberRange | |
{ | |
[cmdletbinding()] | |
Param() | |
DynamicParam { | |
$Dictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary | |
$NewDynParam = @{ | |
Name = "Firstnumber" | |
Alias = "int" |
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
// XPath CheatSheet | |
// To test XPath in your Chrome Debugger: $x('/html/body') | |
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/ | |
// 0. XPath Examples. | |
// More: http://xpath.alephzarro.com/content/cheatsheet.html | |
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class |
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
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
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
Windows Name or Service Pack Version Number | |
---------------------------- -------------- | |
Windows 1.0 1.04 | |
Windows 2.0 2.11 | |
Windows 3.0 3 | |
Windows NT 3.1 3.10.528 | |
Windows for Workgroups 3.11 3.11 |