- Install OpenSSH
- For domain user on 7.7+ (all lower case): AllowUsers domain\user
- For local user (all lower case): AllowUsers user
- run-as user to create profile (or log-in)
- create .ssh and authorized_keys in the user's profile
- run the fix user key script (program files\openssh)
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
try { | |
$MyProcess = New-Object System.Diagnostics.Process | |
$MyProcess.StartInfo.FileName = "c:\MyProcess.exe" | |
$MyProcess.StartInfo.Arguments = "arguments for process" | |
$MyProcess.StartInfo.UseShellExecute = $false | |
$MyProcess.StartInfo.RedirectStandardInput = $true | |
$MyProcess.Start() | |
$StdIn = $MyProcess.StandardInput | |
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
<# | |
.DESCRIPTION | |
Outputs the SSL protocols that the client is able to successfully use to connect to a server. | |
.NOTES | |
Copyright 2014 Chris Duck | |
http://blog.whatsupduck.net | |
Licensed under the Apache License, Version 2.0 (the "License"); |
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
#This only works in PowerShell 6 and 7 as lower versions don't support -AsHashtable | |
$Dracula = convertfrom-json -AsHashtable @" | |
{ | |
"background" : "#282A36", | |
"black" : "#21222C", | |
"blue" : "#BD93F9", | |
"brightBlack" : "#6272A4", | |
"brightBlue" : "#D6ACFF", | |
"brightCyan" : "#A4FFFF", | |
"brightGreen" : "#69FF94", |
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
$InPath = "c:\activity.tcx" | |
$OutPath = "c:\activity_trimmed.tcx" | |
$x = [xml](get-content $InPath) | |
$x.TrainingCenterDatabase.activities.Activity | %{ | |
$Activity = $_ | |
$Activity.lap | %{ | |
$Lap = $_ | |
$lap.track | %{ | |
$Track = $_ |
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
Properties { | |
if(!$OutDir) { | |
$OutDir = "out" | |
} | |
if(!$ProjectDir) { | |
$ProjectDir = $PSake.build_script_dir | |
} | |
if(!$TargetDir) { | |
$TargetDir = Join-Path -Path $ProjectDir -ChildPath $OutDir | |
} |
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
[System.AppDomain]::CurrentDomain.GetAssemblies().ExportedTypes | %{ | |
$Type = $_ | |
$Type.GetMethods() | Select -Unique Name | %{ | |
$Method = $_ | |
$Name = "Invoke-{0}.{1}" -f $Type.Fullname, $Method.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
$Error.Clear() | |
Try { | |
Get-Process fsdks -ErrorAction Stop | |
} Catch { | |
Write-Error "Couldn't find the process" | |
} | |
#Prints out the error "Couldn't find the process" | |
#This contains 2 objects, the "Couldn't find the process" error, and the original error from Get-Process |
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
$RemoteComputer = "remotecomputer" | |
Invoke-Command -Computer $RemoteComputer -ScriptBlock { import-module bitstransfer; get-module bitstransfer; } | |
$S = New-PSSession -Computer $RemoteComputer | |
Invoke-Command -Session $S -ScriptBlock { Import-Module bitstransfer} | |
Invoke-Command -Session $S -ScriptBlock { get-Module bitstransfer} | |
Remove-PSSession $S |
The PowerShell pipeline unwraps collections. Let's write a function to test to see if something is a collection
function Test-Collection {
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
$InputObject
)
process {
$InputObject -is [System.Collections.ICollection]
NewerOlder