21 March 2014

Change error messages text color

the error messages color can be changed using the following command:

$host.PrivateData.ErrorForegroundColor = 'green'

the change will be lost after closing the shell. in order to make this "permanent" you should put the command in the profile file.


18 March 2014

Custom object - the easy way

the hard way:

$customObject = New-Object PSObject
$customObject | Add-Member NoteProperty Name "Marius"
$customObject | Add-Member NoteProperty Age "33"
$customObject | Add-Member NoteProperty Country "Romania"



the easy way:

$customObject = " " | Select-Object Name, Age, Country
$customObject.Name = "Marius"
$customObject.Age = "33"
$customObject.Country = "Romania"