私はpowershellスクリプトを使ってpowershellウィンドウのサイズを設定しようとしています。私が使用しているコードはPowershellのウィンドウサイズ
$pshost = Get-Host
$psWindow = $pshost.UI.RawUI
$newSize =$psWindow.BufferSize
$newSize.Height = 4000
$newSize.Width = 200
$psWindow.BufferSize = $newSize
$newSize = $psWindow.WindowSize
$newSize.Height = 95
$newSize.Width = 150
$psWindow.WindowSize= $newSize
それはほとんどの場合、正常に動作しますが、いくつかの回は、私は特定のデスクトップサイズに誤差を取得することです。たとえば、私は95で試して、私のデスクトップ画面サイズ1440x960では以下のエラーで失敗しました。
Exception setting "WindowSize": "Window cannot be taller than 82.
Parameter name: value.Height
Actual value was 95."
At line:1 char:5
+ $psWindow.WindowSize= $newSize
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], SetValueInvocationException
+ FullyQualifiedErrorId : ExceptionWhenSetting
スクリプトを実行しているマシンで最大ウィンドウサイズの設定を計算し、powershellウィンドウのサイズを設定する方法はありますか?
'.UI.RawUI.MaxWindowSize'(ホストを取得しますか)? –
ありがとうオースティン、それは私に最大値を与えた – Krishna
@ user2344145オースティンのフランス語の答えを受け入れる必要がありますこれを行う最も正しい方法は –