to display the message
PS> $WarningPreference = "Continue"
Write-Warning "Stopping SQL Service..."
or,
PS> $VerbosePreference = "Continue"
Write-Verbose -message "SQL Service has been started. You may proceed..."
(Yellow on Black if powershell.exe in V1.0 or above)
(Black on White if gpowershell.exe in V2CTP2)
(Black on White if powershell_ise.exe in V2CTP3)
Showing posts with label V2CTP2. Show all posts
Showing posts with label V2CTP2. Show all posts
Tuesday, January 20, 2009
Monday, January 19, 2009
two nested for-loops
to display the progress of two nested for-loops
PS> for ($i = 1; $i -lt 101; $i++ )
{for ($j=0;$j -lt 10000;$j++) {} write-progress -activity "Search in Progress" -status "% Complete:" -percentcomplete $i;}
Explanation: The Write-Progress command includes a status bar heading (-activity), a status line, and the variable, $i (the counter in the for-loop), that indicates the relative completeness of the task. The second for-loop is the time counter.
The characters 'Search in Progress', '% Complete:' and repeating 'o' are shown in yellow on a teal progress bar. Graphical Windows PowerShell (V2CTP2) won't see this animation.
PS> for ($i = 1; $i -lt 101; $i++ )
{for ($j=0;$j -lt 10000;$j++) {} write-progress -activity "Search in Progress" -status "% Complete:" -percentcomplete $i;}
Explanation: The Write-Progress command includes a status bar heading (-activity), a status line, and the variable, $i (the counter in the for-loop), that indicates the relative completeness of the task. The second for-loop is the time counter.
The characters 'Search in Progress', '% Complete:' and repeating 'o' are shown in yellow on a teal progress bar. Graphical Windows PowerShell (V2CTP2) won't see this animation.
is .NET CLR 2.0 running now?
to identify NT services' StartMode, ProcessId, and State
PS> Get-WmiObject -Class Win32_Service -ComputerName .
ExitCode : 0
Name : clr_optimization_v2.0.50727_32
ProcessId : 1492
StartMode : Auto
State : Running
Status : OK
When PowerShell v1.0, V2CTP2, or V2CTP3 is used for this project.
PS> Get-WmiObject -Class Win32_Service -ComputerName .
ExitCode : 0
Name : clr_optimization_v2.0.50727_32
ProcessId : 1492
StartMode : Auto
State : Running
Status : OK
When PowerShell v1.0, V2CTP2, or V2CTP3 is used for this project.
Sunday, January 18, 2009
check the version of Windows PowerShell
PS> $PSVersionTable
Name Value
---- -----
CLRVersion 2.0.50727.3053 <--- SP2
BuildVersion 6.1.6585.1 <--- Vista SP1
PSVersion 2.0 <--- V2CTP2/3
PSCompatibleVersions {1.0, 2.0} <--- v1.0 RTM or above
Name Value
---- -----
CLRVersion 2.0.50727.3053 <--- SP2
BuildVersion 6.1.6585.1 <--- Vista SP1
PSVersion 2.0 <--- V2CTP2/3
PSCompatibleVersions {1.0, 2.0} <--- v1.0 RTM or above
Subscribe to:
Posts (Atom)