We have a powershell script which we run manually once every few months to provide our users with an overview of who has access to who's mailbox & vice-versa:
We then import the results to SQL and display them by user via a web page, so each individual accessing the web page sees their specific mailbox details.
What we would like to try and do now is somehow run the script from the web page so that the whole thing becomes dynamic rather than requiring a manual process every few months.
We use Citrix and would intend the Powershell script to run on the Citrix server using parameters to identify who's who.
Can anyone point us in the direction of where to begin, we have got as far as running a simple powershell cmdlet from within an ASP.NET page (locally in a test environment) following the example given here: http://devinfra-us.blogspot.co.uk/2011/02/using-powershell-20-from-aspnet-part-1.html
But I think we are now starting to appreciate the complexity of what to do next...some general guidance at this stage would be appreaciated.
ASP.NETPowershellC#
Last Comment
forsters
8/22/2022 - Mon
Meir Rivkin
>>But I think we are now starting to appreciate the complexity of what to do next...some general guidance at this stage would be appreciated.
I run the example from the link you've posted and it seems to work fine.
what problems you encounter applying this in your environment?
forsters
ASKER
Hi sedgwick,
My apologies, there are no problems running the linked example locally on my machine, no that works fine...agreed, but that was merely to illustrate our first step in trying to understand the process of running powershell scripts via ASP.NET. It's getting from that fairly simple example to what we want to do that seems more complex.
As I said, we want the powershell script to run on our Citrix server not locally on an individuals PC, We will need the web page to trigger the running of the script and display the results, we don't neccessarily need to embed the script itself in the C# - we could just reference a ps1 file - it's trying to understand how we would be best to do this, any security / connection issues involved and how we can trigger the script to run remotely on a server but specific to the identity of the user who is logged in and requesting the webpage if that makes sense.
Many thanks, I will try and tackle one thing at a time:
I suppose the first thing that we would like to understand is the usings - in that example which works for both you and I the instructions say to add: using System.Management.Automation;
but I note from googling the subject that most suggest the need for two further usings: using System.Collections.ObjectModel;
using System.Management.Automation.Runspaces;
Some also seem to refer to the use of pipelines - for example:
I run the example from the link you've posted and it seems to work fine.
what problems you encounter applying this in your environment?