How to run and use o365info PowerShell menu script 5/5 (8) 9 min read

The purpose if the following article is to enable you to use effectively the “Office 365 PowerShell scripts” that I add to my PowerShell articles.
The PowerShell script that provides can be described as “Menu based” PowerShell scripts.

Each menu performs a particular “task.”

To execute a specific “task” all you need to do is to choose the required menu number, and the PowerShell script will execute the required actions respectively.

Using PowerShell script – First time configurations

To be able to create a remote PowerShell session to Exchange Online and Office 365 (Azure Active Directory), we can use the windows built-in PowerShell console.”

By default, the PowerShell console, disable the option of running the PowerShell script.

To be able to run a PowerShell script, we will need to implement “first-time time configurations,” that will enable us to run a PowerShell script.

Note – the required configuration carried out one time. After we enable the PowerShell console to “allow” the use of PowerShell script, the setting be will be kept.
The next time that we need to run a PowerShell script via the PowerShell console, we just need to “call” the script, and it will appear on the PowerShell console.

1. Locate the PowerShell console.

To be able to find the built-in Windows PowerShell console, use the search option in the start menu by looking for the term – “PowerShell” (number 1).

In the search results, we can see the required PowerShell console named – Windows PowerShell (number 2).

Locate the PowerShell console -01-

2. Running the PowerShell console as Administrator

In the next step, we will run a PowerShell command, that will enable us to run a PowerShell script.

The PowerShell command updates the local registry file.

To be able to update the local registry, we need to run the PowerShell console “As Administrator”

Note – even if you are logged in as “Administrator,” you will still need to run the PowerShell
console “As Administrator

Right click on the Windows PowerShell icon, and choose the
menu – As Administrator

Activate PowerShell console by using the Run as administrator-02-

3. Running the PowerShell command that enables to run PowerShell script.

The PowerShell commands that updates the default PowerShell console restriction is:

Set-ExecutionPolicy Unrestricted –force
  1. Copy the PowerShell command and paste it on the PowerShell console.
  2. To execute the PowerShell command, press the ENTER

In the following screenshot, we can see an example.

Running the Set-ExecutionPolicy PowerShell command -03-

How to use the o365info script

In this section, we describe the process of “calling” the PowerShell script, from the PowerShell console.

Scenario description

In our scenario, we save the PowerShell script named: audit.ps1, to the TEMP folder on drive C:

1. Locate the PowerShell script

Open the PowerShell Console and type: CD C:\TEMP

Locate the PowerShell script -01-

2. Execute\ Activate the PowerShell script

Call the PowerShell script using the following procedure:

  • Type the following charters: .\
  • Type the name of the PowerShell script file (including the suffix).
    For example: audit.ps1
  • Press the ENTER key, to activate the PowerShell Script.

Locate the PowerShell script -02-

Tip use PowerShell Autocomplete future

A useful option that we can use is the PowerShell Autocomplete future.

  • Type the following charters: .\
  • Type the “first 2 letters” of the script file (for example au instead of audit.ps1)

Hit the TAB key.

The PowerShell console Autocomplete feature will automatically complete the rest of the PowerShell script name.

Using remote PowerShell in Office 365 based environment

In Office 365 based environment, we run the required PowerShell command on a “remote infrastructure” such as Azure Active Directory and Exchange Online.

The first step is, to create a “remote PowerShell session” that will enable us to “send the PowerShell commands” that will “run” on the remote infrastructure.

Office 365 infrastructure includes many types of “infrastructures” such as the Azure Active Directory, Exchange Online, SharePoint online, Skype and so on.

Each of these “Offices 365 infrastructure”, requires a different set of PowerShell commands that will use for creating the remote PowerShell connection.

For example

1.  Creating remote PowerShell to Azure Active Directory

To be able to create a remote PowerShell session that will connect us to Office 365 Azure Active Directory, we will need to download and install two software components.

Note – you can read more information the required configuration for creating a remote PowerShell to Azure Active Directory in the article – Using Remote PowerShell to manage Office 365 | Part 2/3

2.  Creating remote PowerShell to Exchange Online

Regarding the task of – creating a remote PowerShell to Exchange Online, the good news is that we don’t need to download and install additional software components.

The remote PowerShell connection to Exchange Online is implemented by using the “standard Windows PowerShell console.”

When we run the required PowerShell command for connecting Exchange Online, after providing our Office 365 Global Administrator credentials, the Exchange Online PowerShell cmdlets will be downloaded automatically to the local desktop, from which we use the PowerShell console.

Login to Exchange Online using remote PowerShell using the PowerShell script

Given that you already configure the PowerShell console to allow running PowerShell script, and that already “call” one of the o365info PowerShell scripts, the o365info PowerShell script menu options presented.

To start the remote PowerShell console with Exchange Online, all you need to do is just press “1” (menu 1”).

Calling the o365info PowerShell menu script -01

The following “user credential’s window” will appear.

Login to Exchange Online using Remote PowerShell -02

You will need to provide the Global Administrator credentials.

Login to Exchange Online using Remote PowerShell -03

In the following screenshot, we can see the PowerShell notification, about the Exchange Online PowerShell cmdlets that are downloaded to our local desktop.

Exchange Online PowerShell cmdlets that are downloaded to our local desktop -04

The “type” of the menus in my PowerShell scripts

The PowerShell scripts include three major types of “actions.”

1.  A menu that performs an action on a particular “user” or specific Exchange Online “mailbox”

When using this type of menu, a prompt will appear, asking you to provide the “identity” of the user or the Exchange Online mailbox on which the PowerShell command will run.

In Exchange Online environment, most of the time, the “identity“ is the Exchange Online mailbox is the “Alias” or the Exchange Online mailbox “E-mail address.”

You can read more about the subject of – “Office 365 objects identity” in the article – Office 365 PowerShell – Help and additional information

2.  A menu that performs “bulk task.”

The meaning of the term “bulk task” in PowerShell environment is an “action” that performs on multiple objects at the same time,

For example, PowerShell command, that will “do something,” to all existing Exchange Online mailboxes or, to all existing Office 365 users.

It is important to me to emphasize that, a “bulk operation,” can have a significant impact on your environment.

The bulk command will change the setting of all the existing “objects” (Exchange Online mailbox or Azure Active Directory users). My advice is to test the PowerShell bulk command on a “test environment” or, to be fully aware and understand the “changes “that are executed by the PowerShell command.

3.  Display information or export information to a file

The third type of PowerShell script menu is a menu that was created for display or exporting information about Exchange Online or Azure Active Directory objects.

For example, view the setting of a specific Exchange Online mailbox or Azure Active Directory user account.

Most of the time, I prefer to provide a PowerShell command that exports the information to various file types such as – TXT, CSV, and HTML.

I export the information to different file types because each of the “file types” has advantages and disadvantages.

For example

  • The main advantage of the CSV file format is, that we can use an application such as Microsoft Excel, for filtering the information that includes in the CSV file.
  • The main advantage of the HTML file format is, that we can view the information in a convenient and simple manner by using a browser.

Using a PowerShell menu script that required user input

In this section, we can view a demonstration of a PowerShell script menu that requires “user input.”

In the particular example, the PowerShell script menu will “activate” the Exchange Online Audit option on a specific Exchange Online mailbox.

Using PowerShell script menu and providing recipient name input -01

After we type the menu number (number 2 in our example), a prompt appears in the PowerShell console, asking us to provide the Exchange Online mailbox name.

The PowerShell script menu output will include (most of the times), three parts:

  • Part 1 – information about what is the “operation” that will be performed (number 1).
  • Part 2 – information about the PowerShell command syntax (number 2).
  • Part 3 – a prompt, that “wait” for the name (identity) of the specific “object” which the PowerShell command will act on it (number 3).

Using PowerShell script menu and providing recipient name input -02

After the PowerShell command executes the required task, most of the time, I provide an Indication about the “changes” that implemented.

For example, a PowerShell menu option that “activate” the Exchange Online Audit option.
The information that displays on the PowerShell console provide us information about the Audit Exchange Online mailbox before the update, and after the update.

Using PowerShell script menu and providing recipient name input -03

Export information to TXT, CSV and HTML using the PowerShell script

One of the most common tasks of the Administrators is, to export data to file.

For example, use the information for troubleshooting, report, analyze the data, backup existing configuration setting and so on.

The exported data could be related to

  • Specific Office 365 user, specific Exchange Online mailbox
  • “Bulk export” that will export information about all existing Azure Active Directory users or all existing Exchange Online mailboxes.

Most of the o365info PowerShell scripts, will include a dedicated “section” that will help you to export various types of “data”.

In the following screenshot, we can see an example to the “export to file section”.

Export information to files using the o365info PowerShell script -01-

In the following example, the PowerShell script menu will export information about the Audit settings of a particular Exchange Online mailbox.

When using an “export menu,” the top part includes information about “what is the information” that exported, and also, the local path which will be used to store the exported files.

Export information to files using the o365info PowerShell script -02-

When we run the PowerShell script export menu, a notification appears on the PowerShell console; that informs you about the “local folder hierarchy” that the PowerShell menu creates.

Export information to files using the o365info PowerShell script -03-

In the following example, we can see the result of the “export command.”

Export information to files using the o365info PowerShell script -04-

Most of the time, the PowerShell export menu will export the information to three types of file formats: Text, CSV, and HTML.

Export information to files using the o365info PowerShell script -05-

In the following screenshot, we can see an example of an HTML report that created.

Export information to files using the o365info PowerShell script -06-

In the following screenshot, we can see an example of a CSV report that created.

Export information to files using the o365info PowerShell script -CSV format -07-

Now it’s Your Turn!
It is important for us to know your opinion on this article

Print Friendly

Related Post

Please rate this

Eyal Doron on EmailEyal Doron on FacebookEyal Doron on GoogleEyal Doron on LinkedinEyal Doron on PinterestEyal Doron on RssEyal Doron on TwitterEyal Doron on WordpressEyal Doron on Youtube
Eyal Doron
Share your knowledge.
It’s a way to achieve immortality.
Dalai Lama

Leave a Reply

Your email address will not be published. Required fields are marked *