![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| Guest | Change Help default behaviour when i type the help command i want the result to show as if i typed help with the -full parameter. can i change the defaults? $hay http://scriptolog.blogspot.com |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Change Help default behaviour We didn't make that configurable. You can write a function to do this: function myhelp {$helpcmd = "get-help -full $args" ;invoke-expression $helpcmd} You could request this as a feature. -- Jeffrey Snover [MSFT] Windows PowerShell Architect Microsoft Corporation This posting is provided "AS IS" with no warranties, no confers rights. Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scr.../hubs/msh.mspx |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Change Help default behaviour You can define your own 'help' function in your profile: filter help($name, [switch]$full = $true) { Invoke-Expression ('get-help -Name:$name -full:$full ' + ($args | join-string " ")) } Note that I've defined Join-String in my profile as this: function Join-String([string]$separator = " ", [switch]$empty = $false, [string[]]$strings = $null) { begin { $result = ""; $list = New-GenericObject System.Collections.Generic.List string $strings; } process { if($empty -or $_) { [void]$list.add($_); } } end { [string]::Join($separator, $list.ToArray()); } } Now 'help' displays full help by default; if you want to suppress this, you can call it with -full:$false : help Get-Command -Full:$false Nick $hay wrote: > when i type the help command i want the result to show > as if i typed help with the -full parameter. > > can i change the defaults? > > $hay > http://scriptolog.blogspot.com > > |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: Change Help default behaviour Yeah, looks like you don't actually need the join-string. I would like to request a feature whereby you can set defaults for cmdlet parameters. Something like this, maybe: Set-CommandDefault -Command:<cmdlet, function, filter> -Parameter:<parameter name> -Value:<some object> Or perhaps put it in a ps1xml file. Nick Jeffrey Snover [MSFT] wrote: > We didn't make that configurable. You can write a function to do this: > function myhelp {$helpcmd = "get-help -full $args" ;invoke-expression > $helpcmd} > > You could request this as a feature. |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: Change Help default behaviour ya... writing my own function was the first choice, something like function Get-HelpExamples([string]$cmd) { & get-help $cmd -examples | more } Set-Alias ghe Get-HelpExamples to get only the examples section 10x all $hay http://scriptolog.blogspot.com |
My System Specs![]() |
| | #6 (permalink) |
| Guest | Re: Change Help default behaviour Nick, You can already do what you want using a slightly different technique. Suppose, as a simple example, you want to make the get-process cmdlet behave like get-process -name sql* Do it like this: PS Function:\> function get-process { >> Microsoft.PowerShell.Management\get-process sql* >> } >> PS Function:\> get-process Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- ------ ----- ----- ----- ------ -- ----------- 383 11 9400 1820 98 12.31 5604 SQLAGENT90 416 6 37968 5124 68 51.88 468 sqlbrowser 332 39 36728 20736 1495 12.09 3484 sqlservr 599 77 160552 135432 1719 197.38 3528 sqlservr 624 18 49316 52168 288 52.66 4476 SqlWb 83 2 940 2220 20 8.45 748 sqlwriter You need to qualify the name inside the curly braces or you get a loop that terminates with an error: PS Function:\> function get-process { >> get-process >> } >> PS Function:\> get-process The script failed due to call depth overflow. The call depth reached 101 and the maximum is 100. When you want to return to default behaviour simply type: del function:get-process I hope that helps. Andrew Watt MVP On Sun, 14 Jan 2007 16:25:43 -0600, Nick Howell <msnews.1.nlhowell@spamgourmet.com> wrote: >I would like to request a feature whereby you can set defaults for cmdlet parameters. Something like this, maybe: > >Set-CommandDefault -Command:<cmdlet, function, filter> -Parameter:<parameter name> -Value:<some object> > >Or perhaps put it in a ps1xml file. |
My System Specs![]() |
| | #7 (permalink) |
| Guest | Re: Change Help default behaviour Oops. Typo in my earlier post. The code that gives an error due to a potentially infinite loop should read : PS Function:\> function get-process { >> get-process sql* >> } >> Andrew Watt MVP On Mon, 15 Jan 2007 14:21:27 +0000, "Andrew Watt [MVP]" <SVGDeveloper@aol.com> wrote: >Nick, > >You can already do what you want using a slightly different technique. > >Suppose, as a simple example, you want to make the get-process cmdlet >behave like > >get-process -name sql* > >Do it like this: > >PS Function:\> function get-process { >>> Microsoft.PowerShell.Management\get-process sql* >>> } >>> >PS Function:\> get-process > >Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName >------- ------ ----- ----- ----- ------ -- ----------- > 383 11 9400 1820 98 12.31 5604 SQLAGENT90 > 416 6 37968 5124 68 51.88 468 sqlbrowser > 332 39 36728 20736 1495 12.09 3484 sqlservr > 599 77 160552 135432 1719 197.38 3528 sqlservr > 624 18 49316 52168 288 52.66 4476 SqlWb > 83 2 940 2220 20 8.45 748 sqlwriter > >You need to qualify the name inside the curly braces or you get a loop >that terminates with an error: > >PS Function:\> function get-process { >>> get-process >>> } >>> >PS Function:\> get-process >The script failed due to call depth overflow. The call depth reached >101 and the maximum is 100. > >When you want to return to default behaviour simply type: > >del function:get-process > >I hope that helps. > >Andrew Watt MVP > >On Sun, 14 Jan 2007 16:25:43 -0600, Nick Howell ><msnews.1.nlhowell@spamgourmet.com> wrote: > >>I would like to request a feature whereby you can set defaults for cmdlet parameters. Something like this, maybe: >> >>Set-CommandDefault -Command:<cmdlet, function, filter> -Parameter:<parameter name> -Value:<some object> >> >>Or perhaps put it in a ps1xml file. |
My System Specs![]() |
| | #8 (permalink) |
| Guest | Re: Change Help default behaviour Didn't think of using a fully qualified cmdlet; nice trick! Nick Andrew Watt [MVP] wrote: > Oops. Typo in my earlier post. The code that gives an error due to a > potentially infinite loop should read : > > PS Function:\> function get-process { >>> get-process sql* >>> } >>> > > Andrew Watt MVP > > On Mon, 15 Jan 2007 14:21:27 +0000, "Andrew Watt [MVP]" > <SVGDeveloper@aol.com> wrote: > >> Nick, >> >> You can already do what you want using a slightly different technique. >> >> Suppose, as a simple example, you want to make the get-process cmdlet >> behave like >> >> get-process -name sql* >> >> Do it like this: >> >> PS Function:\> function get-process { >>>> Microsoft.PowerShell.Management\get-process sql* >>>> } >>>> >> PS Function:\> get-process >> >> Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName >> ------- ------ ----- ----- ----- ------ -- ----------- >> 383 11 9400 1820 98 12.31 5604 SQLAGENT90 >> 416 6 37968 5124 68 51.88 468 sqlbrowser >> 332 39 36728 20736 1495 12.09 3484 sqlservr >> 599 77 160552 135432 1719 197.38 3528 sqlservr >> 624 18 49316 52168 288 52.66 4476 SqlWb >> 83 2 940 2220 20 8.45 748 sqlwriter >> >> You need to qualify the name inside the curly braces or you get a loop >> that terminates with an error: >> >> PS Function:\> function get-process { >>>> get-process >>>> } >>>> >> PS Function:\> get-process >> The script failed due to call depth overflow. The call depth reached >> 101 and the maximum is 100. >> >> When you want to return to default behaviour simply type: >> >> del function:get-process >> >> I hope that helps. >> >> Andrew Watt MVP >> >> On Sun, 14 Jan 2007 16:25:43 -0600, Nick Howell >> <msnews.1.nlhowell@spamgourmet.com> wrote: >> >>> I would like to request a feature whereby you can set defaults for cmdlet parameters. Something like this, maybe: >>> >>> Set-CommandDefault -Command:<cmdlet, function, filter> -Parameter:<parameter name> -Value:<some object> >>> >>> Or perhaps put it in a ps1xml file. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Changing default behaviour of Sleep to Shutdown computer... | Vista General | |||
| Re: Explorer - change to default behaviour | Vista General | |||
| Re: Explorer - change to default behaviour | Vista General | |||
| Vista enumprinters sharename change in behaviour | Vista print fax & scan | |||
| How to change default tab in IE7 | Vista General | |||