Hello,
I am new to the PowerShell programming. I want to extract AD information by providing an input <g class="gr_ gr_127 gr-alert gr_spell gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="127" id="127">csv</g> file with user's first and last name. I don't know how to extract the first and last name column into two different variables for PowerShell to query AD by GiveName and Surname.
Below is the Powershell script which I wrote. Where FirstName and LastName should come from the <g class="gr_ gr_997 gr-alert gr_spell gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="997" id="997">adtest</g>.<g class="gr_ gr_1010 gr-alert gr_spell gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="1010" id="1010">csv</g> input rows.
Any suggestion?
adtest.csv file:
Brandon Ho
Jerry Smith
Import-Module ActiveDirectory $aResults = @() $List = Get-Content "C:\Temp\adtest.csv" ForEach($Item in $List){ $Item = $Item.Trim() $User = Get-ADUser -Filter {GiveName -like 'FirstName' -and Surname -like 'LastName'} -Properties SamAccountName, UserPrincipalName $hItemDetails = New-Object -TypeName psobject -Property @{ DisplayName = $Item LoginID = $User.SamAccountName Email = $User.UserPrincipalName } $aResults += $hItemDetails } $aResults | Export-CSV "C:\Temp\Results.csv"