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
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
The following exists in the WSMan help file (PS > help WSMan)
<snip>
-TrustedHosts <String>
...
...
Note: When the TrustedHosts value is set with the Set-Item cmdlet,
the Set-Item cmdlet supports an additional parameter -Concatenate.
The following example will append a new value (*.domain2.com) to
the old value stored in TrustedHost:
Set-Item .\TrustedHosts *.domain2.com -Concatenate -Force
</snip>
So, dynamic parameters can appear under different conditions. It appears
that the WSMAN provider has some dynamic parameters that appears only when
you are in a WSMAN path, and others that appear only when another parameter
is used.
- The TrustedHosts parameter is available on Set-Item, Clear-Item, and Get-Item
only when the path -eq "WSMAN:".
- When -TrustedHosts is used in Set-Item, the -Concatenate parameter becomes
available.
---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar: http://tinyurl.com/PSToolbar
SL> Hi Hans,
SL>
SL> Concatenate is a dynamic parameter (provider specific paremeter) it
SL> is available
SL> only when you use the cmdlet with the provider data.
SL> That said, I think it has a bug. If you type:
SL> set-item WSMan:\localhost\Client\TrustedHosts -c[TAB]
SL>
SL> and press the tAb key few times then the parameters that gets
SL> completed are only: confirm and credential.
SL>
SL> However, if you type:
SL>
SL> set-item WSMan:\localhost\Client\TrustedHosts -co[TAB]
SL>
SL> the concatenate is added.
SL>
SL> You can read more on the dynamic parameters on the powershell team
SL> blog:
S L> http://blogs.msdn.com/powershell/archive/2009/05/28/adding-custom-cm
SL> dlet-help-for-providers.aspx
SL>
SL> Or by reading the about_providers help file.
SL>
SL> ---
SL> Shay Levy
SL> Windows PowerShell MVP
SL> http://blogs.microsoft.co.il/blogs/ScriptFanatic
SL> PowerShell Toolbar: http://tinyurl.com/PSToolbar
"Shay Levy [MVP]" <n...@addre.ss> schreef in bericht
news:37162f6db06c88...@news.microsoft.com...