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
function Get-ComputerSession { | |
[CmdletBinding()] | |
param( | |
# The computer name to get the current sessions from. Use an empty string for local machine. | |
[Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] | |
[AllowEmptyString()] | |
[String] | |
$ComputerName, | |
# Flattens the output |
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
# Place the file into the source root directory. All files will be recursively copied to target directory. | |
$ErrorActionPreference = 'STOP' | |
$sourceRootDirPath = $PSScriptRoot | |
# Set the target directory. Ensure that you don't select a parent directory. | |
# If you place the script to e.g. "C:\ThisIsMySource", you must provide "ThisIsMySourceDirectory" in the target directory path -> "D:\ThisIsMySourceDirectory" | |
# Don't use just "D:\" | |
$targetRootDirPath = 'E:\Games\Steam\steamapps\common\' + ([System.IO.DirectoryInfo]$sourceRootDirPath).Name | |
# if $useFileChecksum is $false, "LastWriteTimeUtc" and "Size" is used. |
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
# usage: | |
# Get service 'DHCP': | |
# PS> Get-ServiceEx dhcp | |
# | |
# Get kernel driver 'ndis': | |
# PS> Get-ServiceEx ndis | |
# | |
# Get all services which are running via svchost: | |
# PS> Get-ServiceEx -ProcessName svchost | |
# |
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
function Import-Xml { | |
[CmdletBinding(DefaultParameterSetName='Path')] | |
param( | |
[Parameter(ParameterSetName='Path', Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] | |
[ValidateNotNullOrEmpty()] | |
[string[]] | |
$Path, | |
[Parameter(ParameterSetName='LiteralPath', Mandatory=$true, ValueFromPipelineByPropertyName=$true)] | |
[Alias('PSPath', 'LP')] |
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 | |
function Join-Object { | |
<# | |
.SYNOPSIS | |
Join-Object combines two collections based on property names or scriptblocks like a SQL-variant of Group-Object. | |
.DESCRIPTION | |
Join-Object combines two collections based on property names or scriptblocks like a SQL-variant of Group-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
# Examples for PowerShell function 'Get-ServiceEx': | |
# https://gist.github.com/swbbl/3fa226f626abfc5b29b66c2d32c920d0 | |
PS> Get-ServiceEx ndis | |
Type : Driver | |
ServiceType : KernelDriver | |
ServiceName : NDIS | |
DisplayName : NDIS System Driver | |
Description : NDIS System Driver |
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
enum Severity { | |
INFO | |
WARNING | |
ERROR | |
} | |
class LogEntry { | |
[datetime] $DateTime = [datetime]::UtcNow | |
[Severity] $Severity | |
[string] $Message |
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
class ParsedUriParameter { | |
[string]$Key | |
[string]$Value | |
[string]$ValueUnescaped | |
ParsedUriParameter([string]$key, [string]$value) { | |
$this.Key = $key | |
$this.Value = $value | |
$this.ValueUnescaped = [uri]::UnescapeDataString($value) | |
} |