D B
asked on
PowerShell Error with Regex Object
I have code that I've been testing in one environment, with no problems. I've recently moved it into the production environment, and am teasting it in 'phases'. One block of code that was working fine is now giving me an error. The actual code is:
if ([regex]::match($file,'_[0-9]{8}_[0-9]{6,}$').Success = $true)
{
...
}
and the error message I am receiving is:"Success" is a ReadOnly property.
At D:\CABDataImport\common\AutoClientLoad\MoveFilesToStaging.ps1:35 char:51
+ if ([regex]::match($file,'_[0-9]{8}_[0-9]{6,}$'). <<<< Success = $true)
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
oBdA got it first (by seconds). I should have thought of Qlemo's answer. He is correct, a boolean is a boolean.
Live and learn :-)
Live and learn :-)
Open in new window
"-eq" instead of "="
I've made that mistake before too.