Set-Item and the magic -concatenate argument...

  • Follow


Received a powertip email today stating:

Use the -Concatenate switch to add new entries without overwriting existing 
entries:
Set-Item WSMan:\localhost\client\trustedhosts 
10.10.10.10 -force -concatenate

So I ask help for the Set-Item cmdlet, but cannot find the -concatenate 
switch.

On the other hand, typing the statement below, followed by tab-completion, I 
surely see the -concatenate switch:

Set-Item WSMan:\localhost\client\trustedhosts 10.10.10.10 -force -con<TAB>

However, the command below does not recognize the -concatenate switch:

set-item -path alias:np -value c:\windows\notepad.exe -con<TAB>

So there must be something "intelligent" at run-time, probably depending on 
the provider. What is the magic term here? Where/how does tab-completion 
look for relevant arguments?

Thanx,
~Hans





 

0
Reply Hans 11/23/2009 8:58:44 PM

Hi Hans,

Concatenate is a dynamic parameter (provider specific paremeter) it is available 
only when you use the cmdlet with the provider data.
That said, I think it has a bug. If you type:

set-item WSMan:\localhost\Client\TrustedHosts -c[TAB]

and press the tAb key few times then the parameters that gets completed are 
only: confirm and credential.



However, if you type:

set-item WSMan:\localhost\Client\TrustedHosts -co[TAB]

the concatenate is added.


You can read more on the dynamic parameters on the powershell team blog:
http://blogs.msdn.com/powershell/archive/2009/05/28/adding-custom-cmdlet-help-for-providers.aspx

Or by reading the about_providers help file.



---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar: http://tinyurl.com/PSToolbar



HD> Received a powertip email today stating:
HD> 
HD> Use the -Concatenate switch to add new entries without overwriting
HD> existing
HD> entries:
HD> Set-Item WSMan:\localhost\client\trustedhosts
HD> 10.10.10.10 -force -concatenate
HD> So I ask help for the Set-Item cmdlet, but cannot find the
HD> -concatenate switch.
HD> 
HD> On the other hand, typing the statement below, followed by
HD> tab-completion, I surely see the -concatenate switch:
HD> 
HD> Set-Item WSMan:\localhost\client\trustedhosts 10.10.10.10 -force
HD> -con<TAB>
HD> 
HD> However, the command below does not recognize the -concatenate
HD> switch:
HD> 
HD> set-item -path alias:np -value c:\windows\notepad.exe -con<TAB>
HD> 
HD> So there must be something "intelligent" at run-time, probably
HD> depending on the provider. What is the magic term here? Where/how
HD> does tab-completion look for relevant arguments?
HD> 
HD> Thanx,
HD> ~Hans


0
Reply Shay 11/23/2009 10:37:24 PM


1 Replies
373 Views

(page loaded in 0.035 seconds)

Similiar Articles:













7/18/2012 2:46:55 PM


Reply: