Powershell and configuring settings - how to remove a setting?

This is mostly a general question. I'll give an example for the sake of asking this question but this is more about how to "unset" settings from a general sense.

Here's what I mean, and maybe it's just my noob-ness to Powershell or the specific technology, but when I need to configure something, and I google around and find that the only way Windows allows this setting to be configured is via Powershell, and then I find an example command to run to make the intended change.

Just for example's sake, say I needed to set an allowed VLAN list on a virtual machine and set it to trunk mode, and i found this as the command:

Set-VMNetworkAdapterVlan –VMName MY_VM_NAME –Trunk –AllowedVlanIdList 201-230 –NativeVlanId 201

So OK great, I run the command and bingo it's done.

But - what if I later decide I want to revert back? If I just needed to change the allowed VLAN range I know I can just re-run the same command with the new values.

But what if I changed my mind, I don't want an vlan range restriction, and/or I no longer want this in Trunk mode.

Microsoft's help page just gives all the different possible settings:

In a Windows GUI at least you have some way to look at the settings and see what other options there are (dropdown or radio buttons for example).  In Linux in most cases configurations are in a text file that is easily browsed and normally commented.

In Windows, where a setting can only be set via Powershell, I seem to always run into situations where I know that once a make a change this way, I'll have no idea how to revert back if needed.

I guess I'm just looking for some advice on how others deal with this, and how you learn more about the different options.  I know how to get help for a module but then once it's deep in the switches/options I'm not always clear when building a powershell command how to get details on the switch options (from within Powershell), and even if I did it would probably still look similar to technet and not really explain how to reset something back to default.

Any advice or guidance would be appreciated.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris DentPowerShell DeveloperCommented:
Good morning,

Inside PowerShell you should be able to run (for example):
Get-Help Set-VMNetworkAdapterVlan -Parameter Access

Open in new window

You can see in the description of the particular CmdLet that the different VLAN tagging options are all mutually exclusive, so it should get very upset if you were to try this:
Set-VMNetworkAdapterVlan -VMName MY_VM_NAME -Trunk -Access

Open in new window

To revert the change you would, of course, need to be aware of the previous setting. But the options are there in the CmdLet to change it as you see fit.

If you just wanted to see the examples for a CmdLet:
Get-Help Set-VMNetworkAdapterVlan -Examples

Open in new window

If you're not sure what you're looking for your best bet is one of the two below:
Get-Help Set-VMNetworkAdapterVlan -Full
Get-Help Set-VMNetworkAdapterVlan -Full | more

Open in new window

Help is normally also published on TechNet (almost always for MS CmdLets):


However, it should be noted that you must mind the Version (directly beneath the CmdLet name) because things always change and not all options are available to all versions of any given Cmdlet.

If you're not sure what command you need, you may be able to work with the generally well structured naming in PowerShell. For example, you might look at the lists returned by:
Get-Help *vlan*
Get-Command *vlan*

Open in new window

Or you may just look at everything a particular module offers:
Get-Command -Module Hyper-V

Open in new window

Not sure what modules you have? You can use this to see:
Get-Module -ListAvailable

Open in new window

In many cases, parameters which expect certain types of input will let you tab through all of the possibilities. For example:
Get-Help -Name <Tab,Tab,Tab,Tab>

Open in new window

While that one isn't the most practical example the same applies to many CmdLets. You can tab through the parameter names in a similar manner.

It goes on and on really. PowerShell is a bit of an explorers language if you start to dig into it (and have the interest to do so). If you don't want to dig in, a small number of "template" scripts can take you a long way. For example, this loop type is repeated again and again:
Get-Something | Where-Object { $_.Property -eq "SomeValue" } | ForEach-Object {
  Do-Something $_.Identity

Open in new window

Finally, you may find these useful:


If you need to capture information about what the current settings are before changing them, there's often a "Get-" command that matches up with a "Set-".  So you could use something like Get-VMNetworkAdapterVlan to see what the settings are before you change them with Set-VMNetworkAdapterVlan.

In all the stuff I do with PowerShell, I rarely if ever encounter something that has a default (certainly nothing's coming to mind right now).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VasAuthor Commented:
Thank you both!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.