@applejxd

雑記帳

PowerShell メモ

目次

実行ポリシー

# 何らかのスクリプトが実行できなかった場合のコマンド
Set-ExecutionPolicy Unrestricted -Force
# プロセス限定
Set-ExecutionPolicy Bypass -Scope Process -Force 

ポートフォワーディング

# 設定
# LP=待受ポート, CP=転送先ポート, IP=転送先アドレス
netsh interface portproxy add v4tov4 listenport=LP listenaddress=0.0.0.0 connectport=CP connectaddress=IP

# 一覧
netsh interface portproxy show all

# 削除
# LP, listenaddress は設定時と同じ値を指定
netsh interface portproxy delete v4tov4 listenport=LP listenaddress=0.0.0.0

ダウンロード

.Net の WebClient を使う方法

(New-Object System.Net.WebClient).DownloadFile('URL','/path/to/save/dir')
(new-object net.webclient).DownloadString('URL')

その他

コマンド実行