I have some missing pieces I can't find answers for...can I get some help?

rated by 0 users
This post has 1 Reply | 1 Follower

Top 50 Contributor
Posts 28
flotsman Posted: 03-05-2010 10:18 AM

Here's the script so far any ideas on how to make the 2 parts come together?

In the first query it finds the data but i want to trim off everything but the login ID. Here's what it is pulling now: 75000032 (GUZMAN,LUZ) . How do a edit out the (GUZMAN,LUZ) ???

Search for all users in OU:

Get-QADUser -SearchRoot 'OU=Partners,DC=xxx,DC=com' | foreach { Write-Output ([char]10) $_.Name;} | out-file C:\Userlist.txt

 

Working script to flip primary

 

$User = Get-content "C:\UserList.txt"

$LogFile = "Logfile.txt"

 

$un = Read-Host "User Name   domain\username"  # Your domain and username

$pw = read-host "Enter password" -AsSecureString # Your Password

connect-QADService -service 'xxx.com' -ConnectionAccount $un -ConnectionPassword $pw

foreach ($User in C:\Userlist.txt) {

Set-QADUser -Identity $User -ObjectAttributes @{primaryGroupID=@(222753)

}

}

 

2 elements I need to complete

 

1.  Way to format list/array to only have the 8 numbers I need on list

2.  At end of script to remove Domain Users from each account being altered.

 

Top 10 Contributor
Posts 555
Microsoft MVP
Top Contributor

one way is to use regular expressions:

'75000032 (GUZMAN,LUZ)' -match '\d*'

$matches.Values

Another one would be to use Split():

'75000032 (GUZMAN,LUZ)'.Split("(")[0].Trim()

Page 1 of 1 (2 items) | RSS
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.