This topic contains 1 reply, has 2 voices, and was last updated by
October 20, 2013 at 3:18 pm #10928ParticipantPoints: 0Rank: Member
how do i, from within powershell, set all those options available after clicking controlbox;Properties (like command history buffer size, font, window color, font color, etc?) i'd like to automate and standardize the setup of powershell across all our servers (rather than having to log into each on individually and run that GUI, over and over and over and ...); that IS the point of powershell, right?
ultimately, these tasks would be included in the overall "what do we need to customize every time we build a new virtual machine" process.
October 20, 2013 at 3:43 pm #10929KeymasterPoints: 1,704Rank: Community Hero
Keep in mind that those things aren't provided by PowerShell, they're provided by that console application, which is basically the same one as used by Cmd.exe, basically. So not EVERYTHING is exposed to PowerShell. But a lot is.
And, to be a little argumentative (I've had whiskey), the point of PowerShell is actually to not log onto the servers at all. You're kinda supposed to have the tools installed on your client computer, or use Remoting, or some-such. Server=handsoff. Not actually trying to create an argument – just pointing out Microsoft's direction on this. They'd much rather you not log directly onto the console at all, since doing so implies you're managing servers on a one-by-one basis, which is definitely contrary to the point. At least, to *their* point. If they could take all user interface off the server entirely, they would. They're kinda trying – see Server Core.
I'd say max bang for buck is enabling remoting in your standard VM build process, and calling it a day. Don't log onto consoles ever. And if you HAVE to, note it as a bug and complain to Microsoft or an app vendor. You shouldn't have to log onto server consoles to manage the server. It's medieval.
The $host variable exposes most of the functionality that you CAN get to.
$host.PrivateData | Get-Member
Shows how you can set colors. You can't actually make this permanent, of course; if you want to set those, you have to create a profile script. You can obviously create a profile that's specific to the console host, but applicable to all users (read about_profiles for the location of that script).
$host.ui.rawui gets you most of the other stuff you're probably after. The names aren't the same as the GUI, but you can probably experiment a bit to figure out what's what.
Again, that's stuff you'd need to put into the profile. Even munging with the GUI, you're really setting options on a per-user basis – that's how the console wants to work. But with the right profile script you can kick in changes for anyone who uses the shell. Of course, the execution policy will need to permit script execution in order for the profile to work, and you should carefully control write access to that all-user profile, since it becomes a convenient way for a malicious colleague to screw people over.
The topic ‘setting powershell options from powershell?’ is closed to new replies.