locked
Powershell GUI with multiple variables from textboxes RRS feed

  • Question

  • Good morning everyone

    I work in a multinational company where we have users from different branch offices that access the same Exchange Online infrastructure, each branch office has its administrator and I need to segment the administration of the quarantine so that each administrator can see only the corresponding quarantined emails.

    To do this, I am developing a script in powershell, which generates a graphical interface so that the administrator can search for emails based on different criteria such as: sender, recipient, subject, message ID, and type.

    Each field is a variable and the text written on the fields pass as parameters. The problem is when the administrator leaves some field blank, it gets an error because the argument lenght is 0. In that case, how do I make the variable ignored if it has no data?

    I appreciate the help you can give me about it.

    Thank you very much, regards.

    Diego
    Friday, February 7, 2020 3:12 PM

All replies

  • Test to see if the $variable -eq $null.

      

     so that each administrator can see only the corresponding quarantined emails.

    If you give them a "plain old script", there is nothing stopping the user from using notepad and modifying it to view everything. You would need to obfuscate it to make it harder to modify. Search the net for "how to obfuscate a powershell script".   

    A better solution might be to use Visual Studio and build a compiled Windows Forms application. Or build an ASPX web site to do this function. That way your code is in one place and you won't have the issue of distributing a script/program to multiple clients.  

    • Proposed as answer by jrv Friday, February 7, 2020 8:46 PM
    Friday, February 7, 2020 3:39 PM
  • Before going any further you should either learn PowerShell or hire a consultant to work with you to help you understand what it is you need to do.  You are asking a lot for a forum that is for answering basic questions about PowerShell.

    A first step is to write the scripts that perform the tasks you need to do.  The CmdLets for Exchange already do most of what you ask.  After you learn how to write a PowerShell script then you will be able to build basic scripts that accomplish the tasks you request.  Once you have the scripts then you can create a form that manages the input in a more convenient way. 

    No matter what you decide to do you have to start by either contacting a consultant or a trained programmer in your company or learn PowerShell and start writing your scripts.


    \_(ツ)_/

    Friday, February 7, 2020 8:52 PM
  • For a place to start and a tool that can do all you ask I suggest looking at the following:

    https://www.sapien.com/software/powershell_studio

    The next link contains hundreds of examples and discussions of how to do what you are asking.

    https://info.sapien.com/

    Here are videos that can help:

    https://www.youtube.com/c/SAPIENTech

    Here is a free and very good book that can also help:

    https://www.sapien.com/books_training/Windows-PowerShell-4

    Here are the necessary documents for using PowerShell with Exchange online:

    https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/exchange-online-powershell?view=exchange-pshttps://docs.microsoft.com/en-us/powershell/exchange/exchange-online/exchange-online-powershell?view=exchange-ps


    \_(ツ)_/

    Saturday, February 8, 2020 1:20 AM
  • Here is a simple hybrid of Visual Studio WPF/XAML forms with a script.

    https://adamtheautomator.com/build-powershell-gui/


    \_(ツ)_/

    Saturday, February 8, 2020 1:42 AM