Stuff
Invoke-XApp (untested) Find-MTU (grabbed from web) Get-FreeDiskSpace (Wmi based) WinCreds package Generate-FancyZones for FancyZones PowerToy
This commit is contained in:
parent
c2675e2346
commit
1c4e9feb1f
|
@ -0,0 +1,13 @@
|
||||||
|
[CmdletBinding()] param (
|
||||||
|
[string]$Pattern
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
cmdkey /list | Where-Object { $_ -like "*Target:*" -and $_ -like "$Pattern" }
|
||||||
|
}
|
||||||
|
|
||||||
|
end {
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
[CmdletBinding(SupportsShouldProcess,ConfirmImpact='High')] param (
|
||||||
|
# Specifies a path to one or more locations.
|
||||||
|
[Parameter(Mandatory=$true,
|
||||||
|
Position=0,
|
||||||
|
ParameterSetName="ParameterSetName",
|
||||||
|
ValueFromPipeline=$true)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[string[]]$EntryName,
|
||||||
|
[switch]$PassThru
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
foreach( $local:entryname_ in $EntryName ) {
|
||||||
|
$local:Entry = $entryname_ -replace " ","" -replace "Target:",""
|
||||||
|
if ($PSCmdlet.ShouldProcess("$Entry", "Remove Credential Entry")) {
|
||||||
|
cmdkey /del:$Entry | Out-Null
|
||||||
|
if( $PassThru ) { Write-Output $Entry }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
end {
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,155 @@
|
||||||
|
<#
|
||||||
|
Generate-FancyZones 'Sz 4K' $(
|
||||||
|
# Generate-FancyZones 'Playground' $(
|
||||||
|
[ordered]@{
|
||||||
|
Q =@(01,01),@(01,13),@(13,01),@(13,13);
|
||||||
|
NT=@(01,01),@(10,01),@(13,01),@(16,01);
|
||||||
|
X1=@(10,01);
|
||||||
|
N1=@(16,01),@(10,01),@(01,01);
|
||||||
|
W1=@(10,01),@(13,01);
|
||||||
|
S1=@(10,01),@(22,01);
|
||||||
|
N3=@(01,11),@(16,01);
|
||||||
|
X3=@(01,11),(10,11);
|
||||||
|
XL=@(01,14),(7,14);
|
||||||
|
XX=@(01,11),(7,11);
|
||||||
|
F3=@(01,11);
|
||||||
|
}) -Verbose -WhatIf
|
||||||
|
|
||||||
|
Generate-FancyZones 'Sz 1920x1080' $(
|
||||||
|
# Generate-FancyZones 'Playground' $(
|
||||||
|
[ordered]@{
|
||||||
|
BNT=@(01,01);
|
||||||
|
BW1=@(11,01);
|
||||||
|
BW2=@(11,12);
|
||||||
|
BSQ=@(11,01),@(11,12),@(15,01),@(15,12)
|
||||||
|
}) -Verbose -WhatIf
|
||||||
|
|
||||||
|
#>
|
||||||
|
|
||||||
|
<#
|
||||||
|
#>
|
||||||
|
[CmdletBinding()]param(
|
||||||
|
|
||||||
|
[ArgumentCompleter({ param (
|
||||||
|
$commandName,
|
||||||
|
$parameterName,
|
||||||
|
$wordToComplete,
|
||||||
|
$commandAst,
|
||||||
|
$fakeBoundParameters
|
||||||
|
)
|
||||||
|
$local:ptDataPath = Join-Path $env:LOCALAPPDATA "Microsoft\PowerToys"
|
||||||
|
$local:fzJsonPath = Join-Path $ptDataPath "FancyZones\zones-settings.json"
|
||||||
|
Get-Content $fzJsonPath | ConvertFrom-Json |
|
||||||
|
Select-Object -ExpandProperty 'custom-zone-sets' |
|
||||||
|
Where-Object 'type' -eq 'canvas' |
|
||||||
|
Select-Object -ExpandProperty name |
|
||||||
|
ForEach-Object {
|
||||||
|
"'$_'"
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
[Parameter(Mandatory,Position=0)]
|
||||||
|
[string]$FancyZoneName,
|
||||||
|
[int]$RatioW=24,[int]$RatioH=24,
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
$presetSizes=[ordered]@{
|
||||||
|
N1 = @(9,10)
|
||||||
|
W1 = @(12,10)
|
||||||
|
X1 = @(15,10)
|
||||||
|
F1 = @(24,10)
|
||||||
|
N2 = @(9,12)
|
||||||
|
X2 = @(15,12)
|
||||||
|
F2 = @(24,12)
|
||||||
|
N3 = @(9,14)
|
||||||
|
W3 = @(12,14)
|
||||||
|
X3 = @(15,14)
|
||||||
|
XL = @(18,11)
|
||||||
|
XX = @(18,14)
|
||||||
|
F3 = @(24,14)
|
||||||
|
NT = @(9,24)
|
||||||
|
WT = @(12,24)
|
||||||
|
XT = @(15,24)
|
||||||
|
S1 = @(3,10)
|
||||||
|
Q = @(12,12)
|
||||||
|
|
||||||
|
BNT = @(10,24)
|
||||||
|
BW1 = @(14,11)
|
||||||
|
BW2 = @(14,13)
|
||||||
|
BSQ = @(10,13)
|
||||||
|
},
|
||||||
|
[Parameter(ParameterSetName="AutoSections",
|
||||||
|
Mandatory,Position=1)]
|
||||||
|
$AutoSections,
|
||||||
|
[Parameter(ParameterSetName="Sections",
|
||||||
|
Mandatory,ValueFromRemainingArguments)]
|
||||||
|
[int[][]]$Sections,
|
||||||
|
[switch]$WhatIf
|
||||||
|
)
|
||||||
|
|
||||||
|
$local:ptDataPath = Join-Path $env:LOCALAPPDATA "Microsoft\PowerToys"
|
||||||
|
$local:fzJsonPath = Join-Path $ptDataPath "FancyZones\zones-settings.json"
|
||||||
|
$fzJson = Get-Content $fzJsonPath | ConvertFrom-Json
|
||||||
|
|
||||||
|
$local:fancyZone = $fzJson.'custom-zone-sets' |
|
||||||
|
Where-Object 'type' -eq 'canvas' |
|
||||||
|
Where-Object 'name' -eq $FancyZoneName
|
||||||
|
|
||||||
|
if( -not $fancyZone ) {
|
||||||
|
Write-Error "`nFancy Zone $FancyZoneName not matched to a valid zone`n`n"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
$local:TotalWidth = $fancyZone.info.'ref-width'
|
||||||
|
$local:TotalHeight = $fancyZone.info.'ref-height'
|
||||||
|
|
||||||
|
$local:wFactor = $TotalWidth / $RatioW
|
||||||
|
$local:hFactor = $TotalHeight / $RatioH
|
||||||
|
|
||||||
|
Write-Verbose "$(
|
||||||
|
)$($fancyZone.uuid) - $($fancyZone.name)`n$(" "*10
|
||||||
|
)W = $TotalWidth / $RatioW = $([Math]::Round($wFactor,3)); $(
|
||||||
|
)H = $TotalHeight / $RatioH = $([Math]::Round($hFactor,3));"
|
||||||
|
|
||||||
|
$fancyZone.info.zones = @()
|
||||||
|
if( $AutoSections ) {
|
||||||
|
foreach( $local:p in $AutoSections.Keys ) {
|
||||||
|
$local:psW = [Math]::Round(($presetSizes."$p")[0] * $wFactor,0)
|
||||||
|
$local:psH = [Math]::Round(($presetSizes."$p")[1] * $hFactor,0)
|
||||||
|
$local:pairs = $AutoSections[$p]
|
||||||
|
if( $pairs[0] -is [int] ) {
|
||||||
|
$pairs = , $pairs
|
||||||
|
}
|
||||||
|
foreach( $local:s in $pairs ) {
|
||||||
|
Write-Verbose "$p : $($s | Join-String ", ")"
|
||||||
|
$fancyZone.info.zones += [ordered]@{
|
||||||
|
X = [Math]::Round(($s[0] - 1) * $wFactor,0)
|
||||||
|
Y = [Math]::Round(($s[1] - 1) * $hFactor,0)
|
||||||
|
width = $psW
|
||||||
|
height = $psH
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
foreach ( $local:s in $Sections ) {
|
||||||
|
$fancyZone.info.zones += [ordered]@{
|
||||||
|
X = [Math]::Round($s[0] * $wFactor,0)
|
||||||
|
Y = [Math]::Round($s[1] * $hFactor,0)
|
||||||
|
width = [Math]::Round($s[2] * $wFactor,0)
|
||||||
|
height = [Math]::Round($s[3] * $hFactor,0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$fzJson.'custom-zone-sets' |
|
||||||
|
Where-Object name -eq $FancyZoneName |
|
||||||
|
ForEach-Object {
|
||||||
|
$_.info.zones = $fancyZone.info.zones
|
||||||
|
}
|
||||||
|
|
||||||
|
if( -not $WhatIf -and -not $WhatIfPreference ) {
|
||||||
|
if( -not (Test-Path "$fzJsonPath.bak") ) {
|
||||||
|
Copy-Item $fzJsonPath "$fzJsonPath.bak"
|
||||||
|
}
|
||||||
|
$fzJson | ConvertTo-Json -Depth 5 | Out-File $fzJsonPath
|
||||||
|
} else {
|
||||||
|
$fancyZone | ConvertTo-Json -Depth 5
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
<#
|
||||||
|
|
||||||
|
.SYNOPSIS
|
||||||
|
Sends ICMPv4 echo request packets to a given IPv4 address
|
||||||
|
with various payload sizes until the maximum transmission unit is found.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Inspired by the script of Charles_1.0 I created a function that uses
|
||||||
|
the .Net ping class to find the biggest transmission unit size.
|
||||||
|
It simple and fast.
|
||||||
|
Just open Powershell, run the script and type Find-MTU <ipaddress> to get the result.
|
||||||
|
|
||||||
|
.INPUTS
|
||||||
|
None
|
||||||
|
You cannot pipe input to this cmdlet.
|
||||||
|
|
||||||
|
.OUTPUTS
|
||||||
|
The function returns an integer that represents the MTU size.
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Author: G.A.F.F. Jakobs
|
||||||
|
Version: 1.3
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Find-MTU 192.168.1.254
|
||||||
|
|
||||||
|
.LINK
|
||||||
|
http://gallery.technet.microsoft.com/Find-the-Biggest-MTU-size-ff1c6069
|
||||||
|
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding(SupportsShouldProcess=$True,ConfirmImpact='Low')]
|
||||||
|
Param(
|
||||||
|
[parameter(Mandatory = $true, Position = 0)]
|
||||||
|
[System.Net.IPAddress]$IPaddress
|
||||||
|
)
|
||||||
|
|
||||||
|
$Ping = New-Object System.Net.NetworkInformation.Ping
|
||||||
|
$PingOptions = New-Object System.Net.NetworkInformation.PingOptions
|
||||||
|
$PingOptions.DontFragment = $true
|
||||||
|
|
||||||
|
[int]$Timeout = 1000
|
||||||
|
[int]$SmallMTU=1
|
||||||
|
[int]$LargeMTU=35840
|
||||||
|
|
||||||
|
[byte[]]$databuffer = ,0xAC * $LargeMTU
|
||||||
|
|
||||||
|
|
||||||
|
#action
|
||||||
|
|
||||||
|
While (-not ($SmallMTU -eq ($LargeMTU - 1))) {
|
||||||
|
[int]$xTest= ($LargeMTU - $SmallMTU) / 2 + $SmallMTU
|
||||||
|
|
||||||
|
$PingReply = $Ping.Send($IPaddress, $Timeout, $($DataBuffer[1..$xTest]), $PingOptions)
|
||||||
|
Write-Verbose "testing $($xTest + 28) byte transmission unit size"
|
||||||
|
if ($PingReply.Status -match "Success"){
|
||||||
|
$SmallMTU = $xTest
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$LargeMTU = $xTest
|
||||||
|
}
|
||||||
|
Start-Sleep -Milliseconds 50
|
||||||
|
}
|
||||||
|
|
||||||
|
If($SmallMTU -eq 1){
|
||||||
|
Write-Error "The IP address $IPaddress does not respond."
|
||||||
|
}else{
|
||||||
|
return $SmallMTU + 28 # add 28 bytes because 20 bytes are reserved for the IP header and 8 bytes must be allocated for the ICMP Echo Request header.
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
Get-CimInstance -ClassName Win32_LogicalDisk | Select-Object -Property DeviceID,@{'Name' = 'FreeSpace (GB)'; Expression= { [int]($_.FreeSpace / 1GB) }}
|
|
@ -0,0 +1,107 @@
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Invoke a graphical application on X-Server.
|
||||||
|
.DESCRIPTION
|
||||||
|
Invoke a graphical application, making sure an X server connection is active, start the x-server if needed, and if the application is remote, make sure the remote session has the correct DISPLAY values set.
|
||||||
|
.INPUTS
|
||||||
|
Inputs to this cmdlet (if any)
|
||||||
|
.OUTPUTS
|
||||||
|
Output from this cmdlet (if any)
|
||||||
|
.NOTES
|
||||||
|
General notes
|
||||||
|
.EXAMPLE
|
||||||
|
Invoke-XApp xclock
|
||||||
|
.EXAMPLE
|
||||||
|
Invoke-XApp xclock -Remote remote@example.com
|
||||||
|
.COMPONENT
|
||||||
|
The component this cmdlet belongs to
|
||||||
|
.ROLE
|
||||||
|
The role this cmdlet belongs to
|
||||||
|
.FUNCTIONALITY
|
||||||
|
The functionality that best describes this cmdlet
|
||||||
|
#>
|
||||||
|
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')]
|
||||||
|
#[OutputType([String])]
|
||||||
|
|
||||||
|
# # Param2 help description
|
||||||
|
# [Parameter(ParameterSetName='Parameter Set 1')]
|
||||||
|
# [AllowNull()]
|
||||||
|
# [AllowEmptyCollection()]
|
||||||
|
# [AllowEmptyString()]
|
||||||
|
# [ValidateScript({$true})]
|
||||||
|
# [ValidateRange(0,5)]
|
||||||
|
# [int]
|
||||||
|
# $Param2,
|
||||||
|
|
||||||
|
# # Param3 help description
|
||||||
|
# [Parameter(ParameterSetName='Another Parameter Set')]
|
||||||
|
# [ValidatePattern("[a-z]*")]
|
||||||
|
# [ValidateLength(0,15)]
|
||||||
|
# [String]
|
||||||
|
# $Param3
|
||||||
|
Param (
|
||||||
|
# Param1 help description
|
||||||
|
[Parameter(Mandatory, Position = 0, ParameterSetName = 'Parameter Set 1')]
|
||||||
|
[string[]]$Command,
|
||||||
|
[string[]]$Remote,
|
||||||
|
[ValidateSet('pwsh', 'bash', 'zsh', 'sh')]
|
||||||
|
[string]$RemoteShell = 'pwsh',
|
||||||
|
[string]$PrivateKeyPath
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
$null = Get-Command 'xlaunch' -ErrorAction Stop
|
||||||
|
|
||||||
|
if ( -not $(Get-Process -ProcessName 'vcxsrv' -ErrorAction SilentlyContinue) ) {
|
||||||
|
|
||||||
|
$local:LaunchCfg = $env:XLAUNCH_CONFIG
|
||||||
|
if ( -not $env:XLAUNCH_CONFIG ) {
|
||||||
|
New-TemporaryFile | Tee-Object -Variable 'LaunchCfg' | Remove-Item
|
||||||
|
}
|
||||||
|
Write-Verbose "LaunchCfg=$LaunchCfg"
|
||||||
|
if ( -not (Test-Path $LaunchCfg) ) {
|
||||||
|
Write-Verbose "Creating missing $LaunchCfg..."
|
||||||
|
New-Item -ItemType File -Path $LaunchCfg -Value @(
|
||||||
|
'<?xml version="1.0" encoding="UTF-8"?>'
|
||||||
|
, '<XLaunch '
|
||||||
|
, ' WindowMode="MultiWindow"'
|
||||||
|
, ' ClientMode="NoClient"'
|
||||||
|
, ' LocalClient="False"'
|
||||||
|
, ' Display="-1"'
|
||||||
|
, ' LocalProgram=""'
|
||||||
|
, ' RemoteProgram=""'
|
||||||
|
, ' RemotePassword=""'
|
||||||
|
, ' PrivateKey=""'
|
||||||
|
, ' RemoteHost=""'
|
||||||
|
, ' RemoteUser=""'
|
||||||
|
, ' XDMCPHost=""'
|
||||||
|
, ' XDMCPBroadcast="False"'
|
||||||
|
, ' XDMCPIndirect="False"'
|
||||||
|
, ' Clipboard="True"'
|
||||||
|
, ' ClipboardPrimary="True"'
|
||||||
|
, ' ExtraParams=""'
|
||||||
|
, ' Wgl="True"'
|
||||||
|
, ' DisableAC="False"'
|
||||||
|
, ' XDMCPTerminate="False"'
|
||||||
|
, '/>' )
|
||||||
|
}
|
||||||
|
|
||||||
|
& xlaunch --run $LaunchCfg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
if ( -not "Command" ) {
|
||||||
|
Write-Warning "No command supplied, exiting."
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ($pscmdlet.ShouldProcess("Target", "Operation")) {
|
||||||
|
if ( $Remote ) {
|
||||||
|
$local:RemoteCommand = "bash", "-c", "'DISPLAY=`"localhost:`"`$( xauth list | awk `"{ print `$1 }`" | cut -d: -f2 | tail -1 ) $Command'"
|
||||||
|
& ssh -i $PrivateKeyPath $Remote $RemoteCommand
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
end {
|
||||||
|
}
|
Binary file not shown.
Loading…
Reference in New Issue