1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Windowes 小ネタ

Last updated at Posted at 2023-12-14

:flag_jp:Japanese notation

Windows11_icon.png

はじめに

初心者対応構成

  • スクリプトでの自動設定
  • UCIとLuCi及びWinSCPにて比較しながら作業がおススメ

PowerShellSSHアクセス

パワーシェル7のインストールとショートカット作成
  • PowerShell 5.1 環境でPowerShell 7のインストールとショートカット作成のスクリプト(デスクトップ)
powershell
$currentVersion = $PSVersionTable.PSVersion
Write-Host "Current PowerShell version: $($currentVersion)"
$installed = Get-Command pwsh -ErrorAction SilentlyContinue
if ($installed) {
    Write-Host "PowerShell 7 is already installed. Skipping installation."
} else {
    Write-Host "Installing PowerShell 7..."
    $url = "https://aka.ms/install-powershell.ps1"
    Invoke-WebRequest -Uri $url -OutFile "install-powershell.ps1"
    .\install-powershell.ps1
    Write-Host "PowerShell 7 installation completed."
}
$desktop = [Environment]::GetFolderPath("Desktop")
$shortcutPath = "$desktop\PowerShell 7 (Admin).lnk"
$targetPath = "C:\Program Files\PowerShell\7\pwsh.exe"
$arguments = "-Command Start-Process pwsh -Verb runAs"
$shell = New-Object -ComObject WScript.Shell
$shortcut = $shell.CreateShortcut($shortcutPath)
$shortcut.TargetPath = $targetPath
$shortcut.Arguments = $arguments
$shortcut.Description = "PowerShell 7 Administrator Shortcut"
$shortcut.WorkingDirectory = "$HOME"
$shortcut.IconLocation = $targetPath
$shortcut.Save()
Write-Host "PowerShell 7 administrator shortcut has been created."


ssh root@192.168.1.1
ssh root@192.168.1.1のショートカット作成(デスクトップ)
powershell
$DESKTOP = ([Environment]::GetFolderPath("Desktop") + "\192.168.1.1.lnk")
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$DESKTOP")
$Shortcut.TargetPath = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
$Shortcut.Arguments = '-windowstyle hidden -ExecutionPolicy RemoteSigned "Start-Process ssh root@192.168.1.1"'
$Shortcut.IconLocation = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe,0"
$Shortcut.WorkingDirectory = "."
$Shortcut.Save()

  • 強制的に貼り付け
  • yes

SSHログイン出来ない場合:exclamation:

known_hostsクリア

  • C:\Users\yourusername\.ssh\known_hosts ※Windows隠しファイル
powershell
Clear-Content .ssh\known_hosts -Force

OpenSSHのインストール
※Windows 10 Fall Creators Update(1709)以降標準搭載

  • 機能の確認
powershell
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
  • 機能のインストール
powershell
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

Windows小ネタ

バッテリーレポート

powercfg /batteryreport

  • ユーザー名取得
(Get-ChildItem Env:USERNAME).Value

  • ブラウザで起動
C:\Windows\system32\battery-report.html
#C:\Users\"ユーザー名"\battery-report.html

ライセンス確認

ライセンス認証結果

cscript "C:\Windows\System32\slmgr.vbs" /dli

プロダクトキー確認

(Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey

ライセンス情報表示

cscript c:\Windows\System32\slmgr.vbs  /dlv

全種ライセンス情報表示

cscript c:\Windows\System32\slmgr.vbs  /dlv  all

端末確認

型名

wmic csproduct get name

製造番号

wmic bios get serialnumber

メモリ診断ツール

mdsched

Windowsエクスペリエンスインデックス

エクスペリエンス インデックス

Get-CimInstance Win32_WinSat

WinSAT

winsat formal

WinSAT結果

C:\Windows\Performance\WinSAT\DataStore

電源プラン「究極のパフォーマンス」

powercfg -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61

SDカード 64GB以上 フォーマット

バッファロー Disk Formatter ダウンロード

ソフトウェアの最新バージョンクローラー

Serva

$LINKS = Invoke-WebRequest "https://www.vercot.com/~serva/download.html" -UseBasicParsing
$LINKS_VERSION = $LINKS.Links | Where-Object {$_.href -like "*Serva_Community_*.zip*"} | Select-Object -ExpandProperty href
$VERSION = ($LINKS_VERSION -split '/')[-1]
Write-Host "Version to install: $VERSION"
$ONAMAE = (whoami).Split('\')[1]
$downloadPath = "C:\Users\$ONAMAE\Downloads\Serva.zip"
Invoke-WebRequest -Uri "https://www.vercot.com/~serva/download/$VERSION" -OutFile $downloadPath
$extractPath = "C:\Users\$ONAMAE\Downloads\Serva"
Expand-Archive -Path $downloadPath -DestinationPath $extractPath -Force
Remove-Item -Path $downloadPath -Force
$installPath = "C:\Program Files\Serva"
if (-not (Test-Path -Path $installPath)) { New-Item -ItemType Directory -Path $installPath -Force }
Copy-Item -Path "$extractPath\*" -Destination $installPath -Recurse -Force
Remove-Item -Path $extractPath -Recurse -Force
if ([Environment]::Is64BitOperatingSystem) { $exePath = "$installPath\Serva64.exe" } else { $exePath = "$installPath\Serva32.exe" }
$desktop = [Environment]::GetFolderPath("Desktop")
$shortcutPath = "$desktop\Serva (Admin).lnk"
$shell = New-Object -ComObject WScript.Shell
$shortcut = $shell.CreateShortcut($shortcutPath)
$shortcut.TargetPath = "$exePath"
$shortcut.Arguments = ""
$shortcut.Description = "Serva Admin"
$shortcut.WorkingDirectory = "$installPath"
$shortcut.IconLocation = "$exePath,0"
$shortcut.Save()
Write-Host "Serva has been installed, and a shortcut has been created on the desktop."

WinSCP

$psVersion = $PSVersionTable.PSVersion.Major
$LINKS = Invoke-WebRequest "https://winscp.net/eng/download.php"
$LINKS_VERSION = $LINKS.Links | Where-Object {$_.href -like "*WinSCP-*-Setup.exe*"} | Select-Object -ExpandProperty href
$VERSION = ($LINKS_VERSION -split '/')[-2] -replace "WinSCP-([0-9]+\.[0-9]+\.[0-9]+).*", '$1'
Write-Host "Version to install: $VERSION"
$downloadUrl = "https://jaist.dl.sourceforge.net/project/winscp/WinSCP/$VERSION/WinSCP-$VERSION-Setup.exe?viasf=1"
Write-Host "Downloading from: $downloadUrl"
$ONAMAE = (whoami).Split('\')[1]
$destinationPath = "C:\Users\$ONAMAE\Downloads\WinSCP-$VERSION-Setup.exe"
Invoke-WebRequest -Uri $downloadUrl -OutFile $destinationPath
Write-Host "Installing WinSCP..."
Start-Process -FilePath $destinationPath -ArgumentList "/VERYSILENT /NORESTART" -Wait
Invoke-Expression "C:\Users\$ONAMAE\AppData\Local\Programs\WinSCP\WinSCP.exe"
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?