What i'm trying to do is create a powershell script which gets a list of folders in a directory which is filtered by a regular expression screening out folder names with nnnnnnx31 or nnnnnnddd where n = alpha chars for the first 6 chararcts and the last 3 is either numbers of the static string x31. Next it screens if the files are 90 days old which will be copied to a different directory.
When i try to run : Posh>get-childitem | where {$.name -match "^\d{6}([a-zA-Z]{3}|x31)$"} | where {$.lastwritetime -lt (get-date.adddays(-90)}
I get the error: You must provide a value expression on the right-hand side of the -lt operator At line: 1 char: 96 + get-childitem | where {$.name -match "^\d{6}([a-zA-Z]{3}|x31)$"} | where {$.lastwritetime -lt <<<< get-date.adddays(-90)}
I also tried the following and it didn't work.. Posh>get-childitem | where {$.name -match "^\d{6}([a-zA-Z]{3}|x31)$"} | where {$.lastwritetime -lt (get-date | foreach-object {$_.adddays(-90)}) }
Any ideas?