Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Powershell and Regular Expressions

$
0
0

Hello All,

I need to use regular expressions within my powershell script to match a specific string of text but I am unsure how to do so, I basically need a pattern that matches the following:

'\\Any Text\' and nothing more.

#Add snap-in and connect to domain


Add-PSSnapin Quest.ActiveRoles.ADManagement | Out-Null

Connect-QADService 'domain' | Out-Null


#Get user who has home drive matching


$Users = Get-QADUser -SizeLimit 0 -SearchRoot 'DCPath' -SearchScope Subtree | Where {$_.HomeDirectory -like '\\anything up until next backslash\'}


#Loop through each user that matches the pattern


ForEach($User in $Users)

{

    Write-Host $User.SAMAccountName

}


Viewing all articles
Browse latest Browse all 6937

Trending Articles