Sign up ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

2 Answers 2

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.