SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a PowerShell script that updates document libraries to make sure that versioning is enabled:

$list.EnableVersioning = $true

How can I check whether versioning is enabled before making the change, so that I don't keep updating the list unnecessarily? I tried the following, but the syntax is incorrect:

if (list.EnableVersioning -ne $true) { $list.EnableVersioning = $true }
share|improve this question
Above code works if I remember to add the $ before list "($list..." – LCountee Jun 25 '12 at 14:58
up vote 2 down vote accepted

If versioning on List is Enabled then perform changes:

  If ($list.EnableVersioning -eq $TRUE) 
     //perform changes

share|improve this answer

This works in my environment


share|improve this answer
This condition will assign $true to the EnableVersioning and evaluate to true regardless of the old value of EnableVersioning – Per Jakobsen Jun 25 '12 at 16:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.