first commit

This commit is contained in:
USER
2023-01-17 16:07:43 +00:00
commit a3c450b2ce
8 changed files with 143 additions and 0 deletions

7
bin/Download.ps1 Executable file
View File

@ -0,0 +1,7 @@
$source = "https://github.com/PowerShell/Win32-OpenSSH/releases/download/v8.9.1.0p1-Beta/OpenSSH-Win64.zip"
$destination = "C:\Packages\OpenSSH-Win64.zip"
Invoke-WebRequest -Uri $source -OutFile $destination
Expand-Archive -LiteralPath $destination -DestinationPath "C:\Packages"
Remove-Item $destination

3
bin/Firewall.ps1 Executable file
View File

@ -0,0 +1,3 @@
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
Set-Service sshd -StartupType Automatic

37
bin/InstallSSH.bat Executable file
View File

@ -0,0 +1,37 @@
@echo off
set check_computername=%COMPUTERNAME%
echo "Found computer %check_computername%"
set PACKAGES="C:\Packages"
set WPUBLIC="C:\wPublic"
mkdir %PACKAGES%
echo "Speed up Powershell processing"
set PSFILE="%WPUBLIC%\bin\SpeedUp.ps1"
Powershell.exe -ExecutionPolicy Bypass -File %PSFILE%
echo "Download and unpack OpenSSH"
set PSFILE="%WPUBLIC%\bin\Download.ps1"
Powershell.exe -ExecutionPolicy Bypass -File %PSFILE%
if exist "C:\Program Files\OpenSSH\sshd.exe" (
echo "OPENSSH already installed"
)
else (
echo "NEW installation"
robocopy "%PACKAGES%\OpenSSH-Win64" "C:\Program Files\OpenSSH" /E
)
if exist "C:\Program Files\OpenSSH\install-sshd.ps1" (
echo "SSH install script"
set PSFILE="C:\Program Files\OpenSSH\install-sshd.ps1"
Powershell.exe -ExecutionPolicy Bypass -File %PSFILE%
)
set PSFILE="%WPUBLIC%\bin\Firewall.ps1"
if exist %PSFILE% (
Powershell.exe -ExecutionPolicy Bypass -File %PSFILE%
net start sshd
)

43
bin/ListSoftware.ps1 Executable file
View File

@ -0,0 +1,43 @@
function listAumids( $userAccount ) {
if ($userAccount -eq "allusers")
{
# Find installed packages for all accounts. Must be run as an administrator in order to use this option.
$installedapps = Get-AppxPackage -allusers
}
elseif ($userAccount)
{
# Find installed packages for the specified account. Must be run as an administrator in order to use this option.
$installedapps = get-AppxPackage -user $userAccount
}
else
{
# Find installed packages for the current account.
$installedapps = get-AppxPackage
}
$aumidList = @()
foreach ($app in $installedapps)
{
foreach ($id in (Get-AppxPackageManifest $app).package.applications.application.id)
{
$aumidList += $app.packagefamilyname + "!" + $id
}
}
return $aumidList
}
# Get a list of AUMIDs for the current account:
listAumids
# Get a list of AUMIDs for an account named “CustomerAccount”:
listAumids("CustomerAccount")
# Get a list of AUMIDs for all accounts on the device:
listAumids("allusers")
get-wmiobject Win32_Product | Format-Table IdentifyingNumber, Name, LocalPackage -AutoSize
Get-AppxPackage -allusers

3
bin/README.md Normal file
View File

@ -0,0 +1,3 @@
InstallSSH.bat in an Administrator command prompt

10
bin/SoftwareList.bat Executable file
View File

@ -0,0 +1,10 @@
@echo off
set check_computername=%COMPUTERNAME%
echo "Found computer %check_computername%"
set PACKAGES="C:\Packages"
set WPUBLIC="C:\wPublic"
echo "Dump software list"
set PSFILE="%WPUBLIC%\bin\ListSoftware.ps1"
Powershell.exe -ExecutionPolicy Bypass -File %PSFILE% > "C:\%check_computername%.txt"

18
bin/SpeedUp.ps1 Executable file
View File

@ -0,0 +1,18 @@
function Optimize-PowershellAssemblies {
# NGEN powershell assembly, improves startup time of powershell by 10x
$old_path = $env:path
try {
$env:path = [Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory()
[AppDomain]::CurrentDomain.GetAssemblies() | % {
if (! $_.location) {continue}
$Name = Split-Path $_.location -leaf
if ($Name.startswith("Microsoft.PowerShell.")) {
Write-Progress -Activity "Native Image Installation" -Status "$name"
ngen install $_.location | % {"`t$_"}
}
}
} finally {
$env:path = $old_path
}
}
Optimize-PowershellAssemblies

22
bin/archive/myBatch.bat Executable file
View File

@ -0,0 +1,22 @@
@echo off
setlocal
set MYDOMAIN=
mkdir c:\Packages\SSH
curl %MYDOMAIN% -o C:\Packages\SSH\InstallSSH.bat
curl %MYDOMAIN% -o C:\Packages\SSH\SpeedUp.ps1
curl %MYDOMAIN% -o C:\Packages\SSH\Download.ps1
curl %MYDOMAIN% -o C:\Packages\SSH\Firewall.ps1
curl %MYDOMAIN% -o C:\Packages\SSH\ListSoftware.ps1
curl %MYDOMAIN% -o C:\Packages\SSH\SoftwareList.bat
echo ""
echo ""
echo ""
echo ""
echo "Run C:\Packages\SSH\InstallSSH.bat in an Administrator command prompt"
echo ""
echo ""
echo ""
echo ""