Powershell to get country from active directory

I am new to PS. We have a requirement to extract country information from the Active Direectory. Can someone please help with the script that can achieve this?

MEHTAB ALAM KHAN,
Welcome to the forum. :wave:t4:

What kind of help exactly do you need? Did you try to search for it first? That’s a quite common task and there are more than enogh examples out there you could adapt to your particular needs.

This forum is for scripting questions rather than script requests. We do not write customized and ready to use scripts or solutions on request.

If you already have code you wrote your self and just got stuck with you are very welcome to share this code here (formatted as code, please) along with a description what’s not working as expected and we will be happy to try to solve your issue togehter with you. :wink:

Thanks for replying back. Yes, I did try running the Powershell script and it was throwing error, probably because the active directory module is missing. Attaching it here for your kind perusal. Is the script correct?

Please do not post images of code - that’s not helpful. Instead past the text and format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code. Please do the same for error messages, console output or sample data.
Thanks in advance

You should NOT create a new post. Please go back, edit your existing one and fix it. :wink: