I’m thinking about making a couple of simple applications using Visual Studio and integrating some of the scripts/queries I have developed for our Active Directory environment.
I’m wondering whether this is at all the way to go, but I just find it tempting because I now know some powershell and want to utilize this and give my users a couple of gui options to run the commands.
But maybe it’s not at all the way to go and maybe I should try and learn the same stuff and run it from C#?
Which approach are you guys taking when you want to build simple windows applications?
I have used Windows Forms in some of my PowerShell Scripts building them from PowerShell alone. I think using a higher level language like C# would only add complexity. You can do it all in PowerShell. At least that has been my experience.
Personally from experience I wouldn’t suggest mixing languages from a debugging point of view, also the example you used was AD, however for get-aduser,get-adgroup to work you also need RSAT installed (Remote Server Administration Tools), if you use native .net you don’t need that as far as I know:-
using System.DirectoryServices.AccountManagement;
using (var pc = new PrincipalContext(ContextType.Domain, "MyDomainName"))
{
var user = UserPrincipal.FindByIdentity(pc, IdentityType.SamAccountName, "MyDomainName\\" + userName);
}
Thanks for your reply!
Yes I stumbled upon some tutorials explaining that this can be build directly from Powershell, and this might be the solution. But I would prefer if I could make an exeutable which users can take and start the program without having to start it from a console.
Interesting! I might take a look at that at some point.
However this is another system which one has to learn My intention was just to make some simple windows desktop apps for my users.
I used a script editor from Sapien many years ago, but that was for vbscript.
It worked great but it was not for creating guis.
I wonder if this is good. I will give it a try.