<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Windows Server HQ by Train Signal.com &#187; Command Prompt</title>
	<atom:link href="http://windowsserver.trainsignal.com/tag/command-prompt/feed" rel="self" type="application/rss+xml" />
	<link>http://windowsserver.trainsignal.com</link>
	<description>We are here to help you learn Windows Server!</description>
	<lastBuildDate>Fri, 20 Aug 2010 16:23:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Take Command of Server 2008 with Windows PowerShell &#8211; Part 4</title>
		<link>http://windowsserver.trainsignal.com/windows-server-2008-powershell-4</link>
		<comments>http://windowsserver.trainsignal.com/windows-server-2008-powershell-4#comments</comments>
		<pubDate>Thu, 21 Feb 2008 16:30:48 +0000</pubDate>
		<dc:creator>Jason Ensinger</dc:creator>
				<category><![CDATA[Server 2008]]></category>
		<category><![CDATA[cmdlets]]></category>
		<category><![CDATA[Command Prompt]]></category>
		<category><![CDATA[Command Shell]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[PowerShell Scripting]]></category>

		<guid isPermaLink="false">http://www.trainsignaltraining.com/windows-server-2008-powershell-4/2008-02-21/</guid>
		<description><![CDATA[In the last couple of weeks you were introduced to the basics of Windows PowerShell, Microsoft&#8217;s new command shell environment.
In Part 1 I talked about what PowerShell is and showed you how to install and access it on Windows Server 2008.
In Part 2 we went over PowerShell cmdlets and PowerShell providers. I showed you how [...]

<h3>Related posts:<ul><li><a href='http://windowsserver.trainsignal.com/windows-server-2008-powershell-2' rel='bookmark' title='Permanent Link: Take Command of Server 2008 with Windows PowerShell &#8211; Part 2'>Take Command of Server 2008 with Windows PowerShell &#8211; Part 2</a></li>
<li><a href='http://windowsserver.trainsignal.com/windows-server-2008-powershell-3' rel='bookmark' title='Permanent Link: Take Command of Server 2008 with Windows PowerShell &#8211; Part 3'>Take Command of Server 2008 with Windows PowerShell &#8211; Part 3</a></li>
<li><a href='http://windowsserver.trainsignal.com/windows-server-2008-powershell' rel='bookmark' title='Permanent Link: Take Command of Server 2008 with Windows PowerShell &#8211; Part 1'>Take Command of Server 2008 with Windows PowerShell &#8211; Part 1</a></li>
</ul></h3>]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.trainsignaltraining.com/wpnew/wp-content/uploads/2008/01/PowerShell2.jpg" alt="Windows PowerShell" title="Windows PowerShell" align="right" width="251" height="200" border="0" />In the last couple of weeks you were introduced to the basics of <strong>Windows PowerShell</strong>, Microsoft&#8217;s new command shell environment.</p>
<p>In <a href="http://windowsserver.trainsignal.com/windows-server-2008-powershell"><strong>Part 1</strong></a> I talked about what PowerShell is and showed you how to install and access it on Windows Server 2008.</p>
<p>In <a href="http://windowsserver.trainsignal.com/windows-server-2008-powershell-2"><strong>Part 2</strong></a> we went over PowerShell cmdlets and PowerShell providers. I showed you how to execute cmdlets and work with the objects returned and also how to use the different PowerShell providers to work with server resources inaccessible from the FileSystem provider.</p>
<p>In <a href="http://windowsserver.trainsignal.com/windows-server-2008-powershell-3/"><strong>Part 3</strong></a> we learned how to customize the user interface with the PowerShell profile.</p>
<p>And now that you are familiar with the capabilities of PowerShell, it is time to learn how to really unleash the power of PowerShell with PowerShell scripting.</p>
<p>Today I&#8217;ll show you how to take advantage of the script engine to automate the performance of Administrative tasks on the Server.</p>
<p><span id="more-423"></span></p>
<h3>Understanding PowerShell Scripting</h3>
<p>If you followed along with the PowerShell customization exercise that I showed you in <a href="http://windowsserver.trainsignal.com/windows-server-2008-powershell-3">the last article</a>, you already know how to create PowerShell scripts. The profile file created in that exercise is actually a PowerShell Script.</p>
<p>In essence, a PowerShell script is simply a text file containing a list of PowerShell commands saved with the file extension .ps1.</p>
<p>For security purposes, script execution is disabled by default. You can set the script execution policy with the <code>Set-ExecutionPolicy</code> cmdlet.</p>
<p>The parameters available for the <code>Set-ExecutionPolicy</code> cmdlet are: <code>-restricted</code>, <code>-unrestricted</code>, <code>-remotesigned</code> and <code>–allsigned</code>. Enter the command: <code>Get-Help Set-ExecutionPolicy –detailed</code> for details on the <code>Set-ExecutionPolicy</code> cmdlet parameters.</p>
<p>In order to exhibit the capabilities of the PowerShell script engine we will go over a sample PowerShell script. The example script was created to display the potential of PowerShell scripting for performing administrative tasks in a server environment.</p>
<p>When the example script is ran, it behaves like a program. It first lists all the printers installed on the server and then prompts you to select one or all of the printers.</p>
<p>Once a printer is selected an additional menu is displayed for operations that can be performed with the printer or printers. When an action is selected, it is performed, then the program begins again at the beginning until you enter ‘exit’ at one of the prompts.</p>
<p>If we examine the script, we can see that it is broken up into three sections. The first section is dedicated to the function definition portion of the script. The second section covers the process of prompting the user. The third section is where the operation chosen is performed on the selected printer.</p>
<pre>
function cancelPrinterJobs {
	$objPrinter = $args[0]
	$objCancel = $objPrinter.CancelAllJobs()
	if ($objCancel.ReturnValue -eq 0) {
		write-host "Cancelled all jobs on"$objPrinter.Name
	}
	else {
		write-host "Cancel of all jobs on"$objPrinter.Name"failed"
	}
}

function pausePrinter {
	$objPrinter = $args[0]
	$objPause = $objPrinter.Pause()
	if ($objPause.ReturnValue -eq 0) {
		write-host $objPrinter.Name"pause"
	}
	else {
		write-host "Pause of"$objPrinter.Name"failed"
	}
}

function resumePrinter {
	$objPrinter = $args[0]
	$objResume = $objPrinter.Resume()
	if ($objResume.ReturnValue -eq 0) {
		write-host $objPrinter.Name" resumed"
	}
	else {
		write-host "Resume of"$objPrinter.Name"failed"
	}
}

function testPrinter {
	$objPrinter = $args[0]
	$objTest = $objPrinter.PrintTestPage()
	if ($objTest.ReturnValue -eq 0) {
		write-host $objPrinter.Name" printed a test page"
	}
	else {
		write-host $objPrinter.Name" test page failed"
	}
}

function setDefaultPrinter {
	$objPrinter = $args[0]
	$objDefault = $objPrinter.SetDefaultPrinter()
	if ($objDefault.ReturnValue -eq 0) {
		write-host $objPrinter.Name" Set as default."
	}
	else {
		write-host "Failed to set"$objPrinter.Name"as default"
	}
}

function writePrinterInfo {
	$objPrinter = $args[0]
	$strComputerName = $args[1]
	$colPrinters = get-wmiobject -class "Win32_PrinterConfiguration" -namespace "root\CIMV2" -computername $strComputerName

	write-host $objPrinter.Name "Printer Information"
	write-host
	write-host "Name: " $objPrinter.Name
	write-host "Driver Name: " $objPrinter.DriverName
	write-host "Port Name: " $objPrinter.PortName
	write-host "Shared: " $objPrinter.Shared
	write-host "Share Name: " $objPrinter.ShareName
	write-host "Queued: " $objPrinter.Queued
	write-host "Status: " $objPrinter.Status

	foreach ($objPrinter in $colPrinters) {
		if ($objPrinter.Name -eq $strPrinterName) {
			write-host "Driver Version: " $objPrinter.DriverVersion
			write-host "Paper Size: " $objPrinter.PaperSize
			write-host "X Resolution: " $objPrinter.XResolution
			write-host "Y Resolution: " $objPrinter.YResolution
			write-host
			break
		}
	}
}
</pre>
<p>In the first section, six functions are defined. Each function performs an action with a printer. The function cmdlet is used to define each function. Immediately after the <code>function</code> cmdlet the function name is supplied, followed by the commands of the function enclosed in curly brackets.</p>
<p>Functions in PowerShell do not support defining the arguments. Instead, functions accept a virtually unlimited number of space-separated objects as arguments. The arguments can be accessed within the function with the $args variable.</p>
<p>When PowerShell executes a script, commands are executed as the script is read rather than loaded to memory and then executed. Therefore, a function must be defined in the script before it is ever called.</p>
<p>It is a good idea to always define all your functions first in a PowerShell script. If a function is called within another function the called function must be defined first.</p>
<p>The first commands of every function are to assign the expected argument to a variable for script readability. All the functions expect a WMI Printer object as the first argument. Only the last function expects a second argument, the computer name.</p>
<p>The first five functions each execute a method of the printer object and assign it to a variable. The return value is checked for successful execution with an &#8220;if&#8221; statement and if the conditions in the parentheses are met the <code>Write-Host</code> cmdlet in the curly brackets is executed to display a success message.</p>
<p>If the successful condition is not met a failure message is displayed from the command in the curly brackets of the else statement.</p>
<p>After the argument variables are assigned in the final function the <code>Get-WMIObject</code> cmdlet is used to assign the Win32_PrinterConfiguration object to a variable. Then select properties from the supplied Printer object are displayed.</p>
<p>After that the <code>Foreach-Object</code> cmdlet is used to loop through the items of the PrinterConfiguration object then checks if its name matches that of the Printer object supplied to the function. When a match is found select properties from the PrinterConfiguration object are displayed and the loop is exited with the <code>break</code> cmdlet.</p>
<pre>
cls

$strComputerName = "."
$colPrinters = get-wmiobject -class "Win32_Printer" -namespace "root\CIMV2" -computername $strComputerName | sort-object "Name"

do {
	$printerIndex = 0
	write-host
	write-host "Installed Printers"
	write-host
	write-host "0) All Printers"

	foreach ($objPrinter in $colPrinters) {
		$printerIndex = $printerIndex + 1
		write-host $printerIndex") "$objPrinter.Name
	}

	write-host

	$selectedPrinterIndex = read-host "Select the printer(s) you wish to work with or type 'exit' to exit"
	if ($selectedPrinterIndex -eq "exit") {
		break
	}
	$validated = 0
	do {
		if ($selectedPrinterIndex -gt $printerIndex) {
			$selectedPrinterIndex = read-host "Please enter a valid printer number"
		}
		else {	$validated = 1 }
	}
	while ($validated -lt 1)

	write-host
	write-host "Printer Operations"
	write-host
	write-host "0) Display Printer(s) Information"
	write-host "1) Cancel Printer(s) Jobs"
	write-host "2) Pause Printer(s)"
	write-host "3) Resume Printer(s)"
	write-host "4) Test Printer(s)"
	if ($selectedPrinterIndex -gt 0) {
		write-host "5) Set Printer As Default"
	}
	write-host

	$selectedOperationIndex = read-host "Select an action to perform on the printer or type 'exit' to exit"
	if ($selectedOperationIndex -eq "exit") {
		break
	}
	$validated = 0
	do {
		if ($selectedOperationIndex -gt 5) {
			$selectedOperationIndex = read-host "Please enter a valid operation number"
		}
		else {
			if ($selectedPrinterIndex -eq 0) {
				if ($selectedOperationIndex -eq 5) {
					$selectedOperationIndex = read-host "Please enter a valid operation number"
				}
				else {	$validated = 1 }
			}
			else {	$validated = 1 }
		}
	}
	while ($validated -lt 1)
</pre>
<p>The second section of the script is where execution begins. The program begins by clearing the console with the <code>cls</code> cmdlet. Next a variable is assigned with the computer name.</p>
<p>When a computer name is expected as a cmdlet parameter the dot used will be interpreted as the local machine. The computer name variable is then used when assigning the WMI Win32_Printer object to a variable.</p>
<p>The <code>DoWhile-Object</code> is executed next and is closed at the end of the script with <code>while (1)</code>. This tells the program to loop execution until the loop is exited with the <code>break</code> cmdlet.</p>
<p>The next four commands display the printer menu title and first option as 0 for selecting all printers. A variable is then created to keep track of the printer index before the <code>foreach-object</code> cmdlet is used to loop through the Printer objects of the Win32_Printer object. Each time through the loop one is added to the printer index then it is displayed with the name of the current Printer object.</p>
<p>After the loop a blank line is displayed to separate the menu items from the prompt. The prompt is displayed with the <code>Read-Host</code> cmdlet and the input is assigned to a variable to represent the index of the selected printer. The printer index variable is then checked if the value is exit and exits the main program loop if so.</p>
<p>A variable is then assigned the value of 0 to represent the input has not been validated. A Do While loop is set to loop until the validation variable equals 1. Enclosed in the loop is an if object that is used to check if the printer index exceeds the number of printers, if so, If the input is invalid the script prompts again for a valid printer index until a valid input is provided by the user.</p>
<p>The second menu is then displayed. An &#8220;if&#8221; statement is used to check if the printer index variable is greater than 0 before the operation to set as the default printer is displayed.</p>
<p>The user is then prompted to enter an operation. Validation for the second menu is done using the same logic as the first menus validation. The difference is an &#8220;if&#8221; statement to check to make sure the operation index supplied is not to set all printers to default.</p>
<pre>
	if ($selectedPrinterIndex -gt 0) {
		$objPrinter = $colPrinters[$selectedPrinterIndex - 1]
	}

	write-host
	switch ($selectedOperationIndex) {
		0 {
			if ($selectedPrinterIndex -eq 0) {
				foreach ($objPrinter in $colPrinters) {
					writePrinterInfo $objPrinter $strComputerName
				}
			}
			else {	writePrinterInfo $objPrinter $strComputerName }
		}
		1 {
			if ($selectedPrinterIndex -eq 0) {
				foreach ($objPrinter in $colPrinters) {
					cancelPrinterJobs $objPrinter
				}
			}
			else {	cancelPrinterJobs $objPrinter }
		}
		2 {
			if ($selectedPrinterIndex -eq 0) {
				foreach ($objPrinter in $colPrinters) {
					pausePrinter $objPrinter
				}
			}
			else {	pausePrinter $objPrinter }
		}
		3 {
			if ($selectedPrinterIndex -eq 0) {
				foreach ($objPrinter in $colPrinters) {
					resumePrinter $objPrinter
				}
			}
			else {	resumePrinter $objPrinter }
		}
		4 {
			if ($selectedPrinterIndex -eq 0) {
				foreach ($objPrinter in $colPrinters) {
					testPrinter $objPrinter
				}
			}
			else {	testPrinter $objPrinter }
		}
		5 {
			setDefaultPrinter $objPrinter
		}
	}
}
while (1)
cls
</pre>
<p>The final section of the script handles performing the selected operation with the selected printer or printers. It starts off by assigning the selected printer object to a variable using the selected printer index if the user did not select all printers.</p>
<p>The control of which operation is to be executed is handled by the Switch cmdlet. Within the curly brackets of the <code>Switch</code> cmdlet the commands executed are the commands within the curly brackets of the number in the <code>Switch</code> cmdlet that match the operation index provided by the user.</p>
<p>In all cases but the last, an if statement is used to check if the selected operation is to be performed on all printers. If all printers have been selected a foreach loop is used to pass all the Printer objects to the proper function otherwise only the Printer object of the selected printer is passed to the function.</p>
<p>The fifth case does not check if all printers were selected because the input validation prevents the option from being able to be selected if all printers are selected. After the switch statement the program’s infinite Do While loop is closed off the screen cleared and execution of the script ends.</p>
<p>Now that you are so familiar with how to create dynamic PowerShell scripts, you probably want to know how to execute a script. To demonstrate, go ahead and copy the commands from all three sections of the script example into notepad and save it to ‘C:\PrinterOperations.ps1’. From PowerShell enter the command below to execute the script.</p>
<pre>
&#038; “C:\PrinterOperations.ps1”
</pre>
<p>With the command above, variable names and functions used in the script will be destroyed when execution completes. If you wish to have script variables and functions available within PowerShell after the script has finished executing you can use dot-sourcing.</p>
<p>The command below will run the script and when execution completes you will have access to the variables and functions created will still be available.</p>
<pre>
&#038; . “C:\PrinterOperations.ps1”
</pre>
<p>I hope that you&#8217;ve enjoyed reading my series on Windows PowerShell.</p>
<p>Keep in mind that there are many additional resources and a number of informative references available on this topic. The owner&#8217;s manual, articles, and many useful scripting examples are available at <a href="http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx">Microsoft TechNet’s Script Center.</a></p>


<h3>Related posts:<ul><li><a href='http://windowsserver.trainsignal.com/windows-server-2008-powershell-2' rel='bookmark' title='Permanent Link: Take Command of Server 2008 with Windows PowerShell &#8211; Part 2'>Take Command of Server 2008 with Windows PowerShell &#8211; Part 2</a></li>
<li><a href='http://windowsserver.trainsignal.com/windows-server-2008-powershell-3' rel='bookmark' title='Permanent Link: Take Command of Server 2008 with Windows PowerShell &#8211; Part 3'>Take Command of Server 2008 with Windows PowerShell &#8211; Part 3</a></li>
<li><a href='http://windowsserver.trainsignal.com/windows-server-2008-powershell' rel='bookmark' title='Permanent Link: Take Command of Server 2008 with Windows PowerShell &#8211; Part 1'>Take Command of Server 2008 with Windows PowerShell &#8211; Part 1</a></li>
</ul></h3>]]></content:encoded>
			<wfw:commentRss>http://windowsserver.trainsignal.com/windows-server-2008-powershell-4/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Take Command of Server 2008 with Windows PowerShell &#8211; Part 3</title>
		<link>http://windowsserver.trainsignal.com/windows-server-2008-powershell-3</link>
		<comments>http://windowsserver.trainsignal.com/windows-server-2008-powershell-3#comments</comments>
		<pubDate>Fri, 15 Feb 2008 16:30:43 +0000</pubDate>
		<dc:creator>Jason Ensinger</dc:creator>
				<category><![CDATA[Server 2008]]></category>
		<category><![CDATA[cmdlets]]></category>
		<category><![CDATA[Command Prompt]]></category>
		<category><![CDATA[Command Shell]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.trainsignaltraining.com/windows-server-2008-powershell-3/2008-02-15/</guid>
		<description><![CDATA[Welcome to part three of taking command of Server 2008 with Windows PowerShell!
You&#8217;ve made it this far, so I&#8217;m assuming you enjoyed part one, where I showed you how to install and access PowerShell, and part two, where I explained PowerShell Cmdlets and PowerShell Providers.
If you missed those two articles, I would suggest reading them [...]

<h3>Related posts:<ul><li><a href='http://windowsserver.trainsignal.com/windows-server-2008-powershell-2' rel='bookmark' title='Permanent Link: Take Command of Server 2008 with Windows PowerShell &#8211; Part 2'>Take Command of Server 2008 with Windows PowerShell &#8211; Part 2</a></li>
<li><a href='http://windowsserver.trainsignal.com/windows-server-2008-powershell' rel='bookmark' title='Permanent Link: Take Command of Server 2008 with Windows PowerShell &#8211; Part 1'>Take Command of Server 2008 with Windows PowerShell &#8211; Part 1</a></li>
<li><a href='http://windowsserver.trainsignal.com/windows-server-2008-powershell-4' rel='bookmark' title='Permanent Link: Take Command of Server 2008 with Windows PowerShell &#8211; Part 4'>Take Command of Server 2008 with Windows PowerShell &#8211; Part 4</a></li>
</ul></h3>]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.trainsignaltraining.com/wpnew/wp-content/uploads/2008/01/PowerShell2.jpg" alt="Windows Power Shell" title="Windows Power Shell" align="right" width="251" height="200" border="0" />Welcome to part three of taking command of Server 2008 with Windows PowerShell!</p>
<p>You&#8217;ve made it this far, so I&#8217;m assuming you enjoyed <a href="http://windowsserver.trainsignal.com/windows-server-2008-powershell"><strong>part one</strong></a>, where I showed you how to install and access PowerShell, and <a href="http://windowsserver.trainsignal.com/windows-server-2008-powershell-2"><strong>part two</strong></a>, where I explained PowerShell Cmdlets and PowerShell Providers.</p>
<p>If you missed those two articles, I would suggest reading them first &#8212; just to make sure you&#8217;ve got all the basics. Now let&#8217;s get started with an exercise in customizing your Windows PowerShell.</p>
<h3>Customizing Windows PowerShell</h3>
<p>Windows PowerShell starts with the same look and feel of the Command Prompt, by default. Let’s make our first exercise of PowerShell power be to customize the PowerShell console.</p>
<p><span id="more-417"></span></p>
<p>The steps below will walk you through customizing the console options then saving those settings to be used every time PowerShell is launched.</p>
<p><strong>1.</strong> Open Windows PowerShell</p>
<p><strong>2.</strong> Create a variable to the PowerShell RawUI object with the command below:</p>
<blockquote>
<pre>
$psui = (get-host).UI.RawUI
</pre>
</blockquote>
<p><strong>3.</strong> Use the $psui variable to change the background and text colors with the commands below:</p>
<blockquote>
<pre>
$psui.WindowTitle = “PowerShell PowerStation”
$psui.BackGroundColor = “Blue”
$psui.ForeGroundColor = “Yellow”
</pre>
</blockquote>
<blockquote><p>
<strong>Note:</strong> The PowerShell console supports 16 colors. They are; Black, White, Blue, Cyan, Gray, Green, Magenta, Red, Yellow, DarkBlue, DarkCyan, DarkGray, DarkGreen, DarkMagenta, DarkRed and DarkYellow.
</p></blockquote>
<p><strong>4.</strong> Use the cls command to clear the console and fill the console with the background color specified</p>
<p><strong>5.</strong> View the other properties available to the object by entering $psui</p>
<blockquote><p>
<strong>Note:</strong> If you wish to change RawUI objects with multiple properties such as the BufferSize property you must assign the property to another variable to modify the object’s properties like the example below:</p>
<pre>
$psbs = $psui.BufferSize
$psbs.Height = 3000
$psbs.Width = 120
</pre>
</blockquote>
<p><strong>6.</strong> Decide on how you want to customize the PowerShell console with the properties available</p>
<p><strong>7.</strong> Open your PowerShell Profile with notepad with the command below:</p>
<blockquote>
<pre>
notepad $profile
</pre>
</blockquote>
<p><strong>8.</strong> Assuming that you are running Server 2008 and this is the first time creating a PowerShell profile, Notepad should display an error that the file was not found.</p>
<p>Click Ok to close the error and return to PowerShell to rectify the problem.</p>
<p><strong>9.</strong> Try using the command below to create the profile file:</p>
<blockquote>
<pre>
create-item $profile –type “file”
</pre>
</blockquote>
<p><strong>10.</strong> The previous command attempts to create the profile file under your ‘Documuents\Windows PowerShell’ directory, but with no Windows PowerShell directory, no file was created</p>
<p><strong>11.</strong> Use some PowerShell power to create the directory then the profile file by entering the commands below:</p>
<blockquote><pre>
new-item $profile.SubString(0, $profile.LastIndexOfAny(“\\”))
create-item $profile –type “file”
</pre>
</blockquote>
<blockquote><p>
<strong>Note:</strong> If you have any experience with the .NET framework the first command of this step should look familiar. It utilizes the methods of the string object to parse the profile path out of the profile variable.
</p></blockquote>
<p><strong>12.</strong> Open the newly created file by entering <code>notepad $profile</code> again</p>
<p><strong>13.</strong> Enter the property changes as you would in PowerShell into the profile file. Below is an example of the contents of a profile file with the same setting examples in these steps:</p>
<blockquote>
<pre>
$psui = (get-host).UI.RawUI
$psbs = $psui.BufferSize
$psui.WindowTitle = “PowerShell PowerStation”
$psui.BackGroundColor = “Blue”
$psui.ForeGroundColor = “Yellow”
$psbs.Height = 3000
$psbs.Width = 120
cls
</pre>
</blockquote>
<p><strong>14.</strong> Click File | Save to save the changes to the profile</p>
<p>If script execution is enabled, when you launch PowerShell it will automatically start with the configuration set in the profile file. If not enabled, proceed to the next section for information on enabling it.</p>
<p>This example only covers customizing the PowerShell console window. Keep in mind that any variables or functions you define in the profile file will be automatically available for use when you launch PowerShell.</p>
<p>This is it for today! Next week we&#8217;ll go into PowerShell scripting &#8212; so don&#8217;t miss the last article of taking command of Server 2008 with Windows PowerShell. See you next week!</p>


<h3>Related posts:<ul><li><a href='http://windowsserver.trainsignal.com/windows-server-2008-powershell-2' rel='bookmark' title='Permanent Link: Take Command of Server 2008 with Windows PowerShell &#8211; Part 2'>Take Command of Server 2008 with Windows PowerShell &#8211; Part 2</a></li>
<li><a href='http://windowsserver.trainsignal.com/windows-server-2008-powershell' rel='bookmark' title='Permanent Link: Take Command of Server 2008 with Windows PowerShell &#8211; Part 1'>Take Command of Server 2008 with Windows PowerShell &#8211; Part 1</a></li>
<li><a href='http://windowsserver.trainsignal.com/windows-server-2008-powershell-4' rel='bookmark' title='Permanent Link: Take Command of Server 2008 with Windows PowerShell &#8211; Part 4'>Take Command of Server 2008 with Windows PowerShell &#8211; Part 4</a></li>
</ul></h3>]]></content:encoded>
			<wfw:commentRss>http://windowsserver.trainsignal.com/windows-server-2008-powershell-3/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
