Asked by:
Use PowerShell to terminate user in AD

Question
-
Hello Every One.
we receive a sheet daily basis with employee status, from a HR tool workday.
there is a column "employee status" the values are - Active, In Leave, Terminated.
I am trying to run a script which will see which all users has an employee state Terminated and export them to a different excel sheet / csv file.
Can someone please help.
Regards
Sugata
Saturday, July 6, 2019 11:24 PM
All replies
-
Can someone please help.
What kind of help do you need? Please show your code.
Before you proceed you should read this first: This forum is for scripting questions rather than script requests.
Also find scripts here: PowerShell Gallery or here: TechNet Gallery - resources for IT professionals.
Learn PowerShell: Microsoft Channel 9 - Getting Started with Microsoft PowerShell 3.0.
Script requests: Microsoft Technet Script Center - Requests.
Live long and prosper!
(79,108,97,102|%{[char]$_})-join''
Saturday, July 6, 2019 11:26 PM -
$user = Get-Content C:\temp\Workday_AD_20190613.csv
$user | foreach {
if ($_ -like "*Terminated*") {Write-Output $_}
}I have sheet Workday_AD_20190613.csv which has all user info
I am running the below to see who all are Terminated as an output i m getting all the users who all are marked as terminated
I need to export them to a CSV
Sunday, July 7, 2019 12:08 AM -
Import-Csv -Path C:\temp\Workday_AD_20190613.csv | where {$_."Emp Status" -eq "Terminated"} | Export-Csv -Path c:\temp\akku.csv
this worked for me
- Proposed as answer by LeeSeenLiMicrosoft contingent staff Monday, July 8, 2019 2:13 AM
Sunday, July 7, 2019 12:39 AM -
this worked for me
Great. I'm proud you. ;-) :-D
Have a nice day.
Live long and prosper!
(79,108,97,102|%{[char]$_})-join''
Sunday, July 7, 2019 12:53 AM -
Hi,
I am glad to hear that your issue was successfully resolved. Please "mark it as answer" to help other community members find the helpful reply quickly.If there is anything else we can do for you, please feel free to post in the forum.
Best Regards,
Lee
Just do it.
Monday, July 8, 2019 2:14 AM