I hesitated for a long time. It’s done, it’s not done… should I add more menus… But at some point it’s over. It has to be published. The following article describes the use of a set of advanced functions. This function presents a menu with a lot of scripts in it. It’s like sconfig, but in relation it’s much more powerful when it comes to Active Directory administration.
*** Update ***
For the lastest version open this link:
Active Directory Domain Services Section (Version 1.1)
The function has grown and grown over time and it’s not a perfect script, but I’m sure it will help many of you out there. If you look inside the script, don’t be afraid of lot’s of Write-Host. Write-Host is not as evil as many say.
Active Directory Domain Services Section
What can we do with it? This is the question for this part. I wanna give you a foretaste. Here’s the menu:
And here are the sub menus:
1 – List all Domain Controllers
2 – Domain Configuration
3 – Forest Configuration
4 – List Windows Clients
5 – List all Windows Server
6 – List all Computer
7 – Systeminfo on Remote Computer
You are able to select a scope …
8 – The Domain Admins
Please note that nested groups are not shown.
9 – Show Optional Features (Recycle Bin …)
10 – List all active (linked) GPOs by Name
11 – Show Default Domain Policy Settings
12 – Show all Active Directory Sites in Detail
13 – Show Users Last Logon
14 – Get a list of all enabled users
15 – List User Details
16 – List Active Directory Groups
17 – List Group Memberships
18 – Send Messages to user’s desktop
Cool, ha? One of my favorites …
19 – Get Logged on User per Workstation
Another cool stuff … Second favorite … 😉
First, provide administrator credentials …
Then enter the computer to query … Petra has logged on to client01.
Ok, that’s it for now.
PowerShell Web Access
You are also able to run this in PowerShell Web Access:
If you haven’t installed PowerShell Web Access yet, here’s a walk through: Windows Server 2012/2016: Installing and Configuring PowerShell Web Access (PSWA)
The Script
I have decided not to present the entire code here. Too many lines of code. You can download the script here, it’s a psm1 file, a PowerShell script module file:
Download: Active Directory Domain Services Section
Prerequisites and Notes:
- Tested in an Active Directory environment with Windows Server 2012/2016 Domain Controllers and Windows 7/8/10 clients
- All operating systems should be installed in English (because of the compatibility with section 19)
- WinRm must be enabled on all Client computers (WinRm is enabled on Windows Server 2012/2016 by default) manually (winrm qc) or by GPO. See Enabling WinRM for Windows Client Operating Systems (Windows 10, Windows 8, Windows 7)
- Run the tool on a Domain Controller (You may run into troubles with RSAT)
- 0 and Enter (instead of Enter only) to go back to the main menu is due to the possible integration of PowerShell Web Access where pressing Enter only will not work
After downloading create a folder “AD” in C:\Program Files\Windows PowerShell\Modules and save the AD.psm1 file there.
It should be then available every time you start PowerShell and run the command ad.
Or as mentioned in PowerShell Web Access.
Have fun with it! I am very grateful for ideas for further functions.
Categories: PowerShell, Windows Server
Hi Patrick, works great, thx for sharing. i am new to PS. you have mentioned “PowerShell Web Access”. I ran 1\2\3 instructions, and when i do “https://localhost/pswa”, showing page not found. Any input how to put this in web service?
LikeLike
Hi Ari,
Thank you for the comment. PowerShell Web Access is a wide topic, I recommend reading my articles to PowerShell Web Access and try again.
The problem you’re faced is not related to my ad script. PSWA is not working correctly. https://localhost/pswa should redirect you to the PowerShell Web Access Login Page.
All the best,
P
LikeLike
When you copy it out to the folder make sure the file is not blocked, that was causing my error below
ad : The term ‘ad’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
Once I unblocked the file it started working, good job. A password reset option would be a good add.
LikeLiked by 1 person
Hi Patrick
All working now! I missed the rename of the .psm1 file and had just copied it directly to the AD folder. Thanks for the quick reponse.
J
LikeLiked by 1 person
Hi Patrick
Thanks for the quick response! Working now. I missed the rename of the .psm1 file and had just copied directly from the download folder to the AD folder.
James
LikeLiked by 1 person
amazing tool ❤ ❤ ❤ great job!!!!!
LikeLike
Thank you!
LikeLike
Cannot test drive this awesome script 😦
The webpage at https://patrick6649.files.wordpress.com/2018/03/ad.zip might be temporarily down or it may have moved permanently to a new web address.
LikeLike
Hi Werner,
I’m sorry for that. Could you please try again? The link should be working fine.
All the best,
P
LikeLike
Thank you for getting it fixed Patrick 🙂
LikeLiked by 1 person
It worked after i changed it to psm1.
LikeLiked by 1 person
Hey Patrick, than you for the quick reply. I tried downloading the file, but i get only the ps1. I pasted id in the mentioned location. but with no luck
PS C:\Users\K3rb\Desktop> ad
ad : The term ‘ad’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
LikeLike
Hey Patrick, impressive work with the script. I am having issues running it, it runs the script, but nothing happens, nor does it display any error. WinRm is started, and running this on a DC. Thanks for the help!
LikeLike
Hi,
I’d need a more detailed error description. Which menu point do you mean?
P
LikeLike
*** EDIT ***
Thank you so much for your hint. I hate those kinds of mistakes. I’ve put the ps1 file in it instead of the psm1 file.
I have now changed the download file so that it contains the correct file.
You’ll need to place the psm1 file in C:\Program Files …
LikeLike
Hi Patrick
Followed the instructions but get the same error as Stefan
ad : The term ‘ad’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
I’ve dropped the .psm1 file into the newly created AD folder as specified but no joy.
LikeLike
Hi,
Make sure your file is ad.psm1 and then make sure you copied it to the right folder. It’s C:\Program Files\WindowsPowerShell\Modules\AD. There’s nothing wrong with my script but PowerShell can’t find it for a reason. Double check your settings.
All the best,
P
LikeLike