Reputation: 317
I am trying to use Start-Process command to invoke another session of powershell. But I want to have the windows size of this new powershell to be small so I am trying to pass the following arguments
$arguments[0] += "New-Variable -Name host1 -Value (Get-Host)"
$arguments[1] += "$aff = $host1.UI.RawUI"
$arguments[2] += "$wff = $aff.WindowSize"
$arguments[3] += "$wff.Width = 10"
$arguments[4] += "$wff.Height = 10"
$arguments[5] += "$aff.WindowSize = $wff"
But it doesnt seem to work.
Any help will be highly appreciated Thanks
Upvotes: 1
Views: 1993
Reputation: 201632
Why not just make the new PowerShell hidden?
Start-Process powershell -WindowStyle Hidden ...
Also, PowerShell variables won't transfer from one PowerShell session to another spawned one. If you need that behavior, then store your info in environment variables e.g.:
$env:Width = '10'
$env:Height = '10'
Upvotes: 1