Powershell -norefresh

avatar

Is there a way I can make the default be to do a no refresh so that when my script does any of the set-RDM-???? commands I do not have to add the -norefresh parameter to every command?

All Comments (4)

avatar

sadly not at this time.

We will take this down as a feature request.
edited by mcote on 5/13/2014

Maurice

avatar

Powershell has a way to do this built-in. Add a line similar to the following to your profile file, or add it to the top of your script:

$PSDefaultParameterValues['Set-RDM-Username:NoRefresh'] = $true

This tells powershell that for the Set-RDM-Username command, the default for the NoRefresh parameter is $true. So it's the equivalent of having -NoRefresh on by default each time you call that Cmdlet. After this, if you did want it to refresh on a particular call, you'd need to add "-NoRefresh:$false" to the command line for that call.

Not sure what version of Powershell would be required for this; it may be a v3 feature and may not work in v2 (I don't know off hand, as I never use anything less than v3 myself).

HTH
edited by OldLost on 5/20/2014
edited by OldLost on 5/20/2014

avatar

@Dale

Thank you for sharing the information, truly helpful. I will keep that in mind next time I write a PS script.

Regards,

Stéfane Lavergne

avatar

Dale!

Your first post is to give a solution!!! Thank you.

Here's the trophy, you have it for a month! ;)

Maurice

trophy_small[2].jpg