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 }
  • 2
    Above code works if I remember to add the $ before list "($list..."
    – LFurness
    Jun 25, 2012 at 14:58

2 Answers 2


If versioning on List is Enabled then perform changes:

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


This works in my environment


  • 3
    This condition will assign $true to the EnableVersioning and evaluate to true regardless of the old value of EnableVersioning Jun 25, 2012 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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