commit a3c450b2ce5dac01f95af286f3e2da3978b2c402 Author: USER Date: Tue Jan 17 16:07:43 2023 +0000 first commit diff --git a/bin/Download.ps1 b/bin/Download.ps1 new file mode 100755 index 0000000..497a57e --- /dev/null +++ b/bin/Download.ps1 @@ -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 diff --git a/bin/Firewall.ps1 b/bin/Firewall.ps1 new file mode 100755 index 0000000..0925a68 --- /dev/null +++ b/bin/Firewall.ps1 @@ -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 \ No newline at end of file diff --git a/bin/InstallSSH.bat b/bin/InstallSSH.bat new file mode 100755 index 0000000..23cbaa6 --- /dev/null +++ b/bin/InstallSSH.bat @@ -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 +) diff --git a/bin/ListSoftware.ps1 b/bin/ListSoftware.ps1 new file mode 100755 index 0000000..88adf82 --- /dev/null +++ b/bin/ListSoftware.ps1 @@ -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 \ No newline at end of file diff --git a/bin/README.md b/bin/README.md new file mode 100644 index 0000000..15af228 --- /dev/null +++ b/bin/README.md @@ -0,0 +1,3 @@ + +InstallSSH.bat in an Administrator command prompt + diff --git a/bin/SoftwareList.bat b/bin/SoftwareList.bat new file mode 100755 index 0000000..27941f3 --- /dev/null +++ b/bin/SoftwareList.bat @@ -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" diff --git a/bin/SpeedUp.ps1 b/bin/SpeedUp.ps1 new file mode 100755 index 0000000..4055d5e --- /dev/null +++ b/bin/SpeedUp.ps1 @@ -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 diff --git a/bin/archive/myBatch.bat b/bin/archive/myBatch.bat new file mode 100755 index 0000000..811a182 --- /dev/null +++ b/bin/archive/myBatch.bat @@ -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 ""