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.
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()