PowerShell
コマンドプロンプトに代わる新しいターミナルのイメージ
https://docs.microsoft.com/ja-jp/powershell/
powershellのTIPS(ファイル結合とか、ファイル操作)にもいろいろ書いてるはず
powershellの起動時初期フォルダを変更する方法
Run
$ Start-Process powershell.exe -Verb runas
そもそも
PowerShell
Windows Powershell
ってちがうんか?
https://gyazo.com/fc91cbdc8d9f26e54009c73215489067
UTF8で起動する
code:sample.ps1
$ %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command "chcp 65001"
https://www.oresamalabo.net/entry/2021/09/15/003143
あとから変更する
SJIS
$ chcp 932
UTF8
$ chcp 65001
https://docs.microsoft.com/ja-jp/windows/win32/intl/code-page-identifiers
文字化けするのはこれの問題か??
コマンドプロンプトをUTF8で起動する
$ %windir%\system32\cmd.exe /k "chcp 65001"
touchコマンド/新規ファイル作成
$ New-Item -type file aaaaa
powershellの起動時初期フォルダを変更する方法
$_」の意味
shellでいう、> みたいなかんじっぽいな
1つの前の変数の実行結果を渡す的な
https://nabelog.org/400/
日付変換
$ $day =DateTime::DaysInMonth($year, $mm)
$ $targetday=Datetime::Parse("$year/$mm/$day")
実行どうやるんだっけ?
NumLOCKの状態を表示する
$ console::NumberLock
文字コードを表示する
$ Console::OutputEncoding
あんま関係ないか?これ?chcpの設定しても変わらん
$ $OutputEncoding = System.Text.Encoding::UTF8
$ $OutputEncoding = System.Text.Encoding::GetEncoding("Shift-JIS")
$ $OutputEncoding = System.Text.Encoding::GetEncoding("UTF-8")
これができるっつーことはほかのキーも行けると思うんだけどなあ名前がわからん。
https://learn.microsoft.com/ja-jp/dotnet/api/system.console.capslock?view=net-7.0
ここにあった!
$ Get-Date -Format "yyyyMMdd_HHmmss" | % { "prefix_{0}.txt" -f $_ }
SSH接続
OpenSSHで接続できるようになってるけどめっちゃばける
$ (Get-Command New-PSSession).ParameterSets.Name
https://learn.microsoft.com/ja-jp/powershell/scripting/learn/remoting/ssh-remoting-in-powershell-core?view=powershell-7.3
$ ssh -o SendEnv="LANG LC_*" -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o PreferredAuthentications=publickey -o IdentityFile=<秘密鍵のパス> -o ConnectTimeout=15 -l <ユーザー名> -e none -C -o ExitOnForwardFailure=yes -o ServerAliveInterval=15 -o ServerAliveCountMax=3 -o Compression=no -o TCPKeepAlive=yes -o RequestTTY=yes -o ForwardAgent=no -o ForwardX11=no -o ForwardX11Trusted=no -o ProxyCommand=none -o GatewayPorts=no -o GSSAPIAuthentication=no -o GSSAPIDelegateCredentials=no -o GSSAPIKeyExchange=no -o GSSAPITrustDNS=no -o GSSAPIStoreCredentialsOnRekey=no -o IPQoS=lowdelay -o KbdInteractiveAuthentication=no -o NumberOfPasswordPrompts=3 -o PKCS11Provider=none -o PubkeyAuthentication=yes -o BatchMode=no -o CheckHostIP=no -o AddressFamily=inet -o Port=<ポート番号> -o AddressFamily=inet6 <ホスト名またはIPアドレス>