Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1349
  • Last Modified:

Powershell regular expression

Hello,

Pls would you advise in this case? In description there is string which contains a date in format "dd.mm.yyyy", I am trying to extract it .

Please would you advice how to save it into variable. I am not sure where I am doing mistake.

I am getting error :   "Expressions are only allowed as the first element of a pipeline."

$mailbox = Get-QADUser -Enabled 'xxx' -IncludedProperties name,description,accountexpires

$test = $mailbox | if ($_.description -ne $null){ [regex]::Match($_.description,"\d{2}\W\d{2}\W\d{4}")}

write $test.value


Many thanks
0
Radim88
Asked:
Radim88
  • 2
1 Solution
 
Radim88Author Commented:
thx

$mailbox = Get-QADUser -Enabled 'CZPRG TFSCalendar'

$test = $mailbox | %{[regex]::Match($_.description,"\d{2}\W\d{2}\W\d{4}")}
 $test.value
0
 
Radim88Author Commented:
thx
0

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now