# Execute the PowerShell Script in Windows PowerShell ISE

## Set up PowerShell

To run the PowerShell script, you must have Owner access on the Azure subscription

1. Download the [PowerShell script file](https://links.maqsoftware.com/3EdETrg) and extract the contents to a folder on your local system. You can run the script either on **Windows** or via **Azure Cloud Shell**.

   **Running the Script on Windows:**

   1. Press the **Windows key**, search for **Windows PowerShell ISE**, and **Run as Adminstrator**.

      <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-8b010c09a4ba70914cbb7020da85e5e189280f8b%2Fpower-shell-ise.png?alt=media" alt=""><figcaption></figcaption></figure>
   2. Click on **File** > **Open...** from the top menu to open the script file.

      <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-679cbfbb1c54e9e49a09e5aaf8b4c86a789ea113%2F13.9.png?alt=media" alt=""><figcaption></figcaption></figure>
   3. Navigate to the extracted folder and select the script inside the **LoadFAST Windows PowerShell Script** folder.

      <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-e4c0c2613ee9e687973b40d35ae3088496372bd9%2F13.10.png?alt=media" alt=""><figcaption></figcaption></figure>
   4. Press **F5 key** or click the green **Play** button in the toolbar to execute the script.

      <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-28f6271b325072f71e02d04faa892812fff52413%2F13.11.png?alt=media" alt=""><figcaption></figcaption></figure>
   5. The script will begin execution and prompt you for input. Provide the required information as requested.

      <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-9713acd65e9a217c150c40eb2cb420fefdc20138%2F13.12.png?alt=media" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
The Windows PowerShell ISE must be opened in the same location as the downloaded PowerShell zip.
{% endhint %}

**For running script in Azure cloud shell**

1. Open [Azure portal](https://portal.azure.com) and launch **Azure cloud shell**.

   <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-5159fa08b8ac5b69de74c83481cfdbdb8dd17d6e%2Fopen-cloud-shell.png?alt=media" alt=""><figcaption></figcaption></figure>
2. Click **Switch to PowerShell**.

   <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-020af728f69589fbe2cac13b11d2ade0e39fea90%2Fswitch-to-ps.png?alt=media" alt=""><figcaption></figcaption></figure>
3. Click **Manage files** to upload your script.

   <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-daee62baa37006d11dc108b89db15363ff468e7b%2Fmanage-files-az.png?alt=media" alt=""><figcaption></figcaption></figure>
4. Upload both files from **LoadFAST Azure PowerShell Script** inside the extracted folder.

   <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-15e5b2e901c6261735b51105ff32082ce6a360cf%2Fupload-files.jpg?alt=media" alt=""><figcaption></figcaption></figure>
5. Run the script using **& './Azure Cloud PowerShell Script.ps1'** command.
6. The script will prompt you for required input. Fill in the information as needed.

   <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-9713acd65e9a217c150c40eb2cb420fefdc20138%2F13.12.png?alt=media" alt=""><figcaption></figcaption></figure>

   If you see an error message after entering inputs

   <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-cfb0032ace9984090dc9a8429b092800d0321781%2Faz-error.png?alt=media" alt=""><figcaption></figcaption></figure>

   Click on **New session** and re-run the script.

   <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-69bf7f3660624a48338fa4a1d3938de75c3be56c%2Fnew-session.png?alt=media" alt=""><figcaption></figcaption></figure>
7. You’ll be prompted to log in. Copy the code shown and click the provided link.

   <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-9f5bdc698438e725b4205aadf23caeae9ebc27db%2Fclick-on-link.png?alt=media" alt=""><figcaption></figcaption></figure>
8. Paste the code into the login screen and sign in with your account.

   <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-ad3254b37edf1664a337fb64c4d8b32aae755c60%2Fenter-code.png?alt=media" alt=""><figcaption></figcaption></figure>
9. After logging in, enter your **client secret** when prompted. The script will now run successfully.

   <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-646fb30de046040e6b9c827c476d437ab480dc52%2Fclient-secret.png?alt=media" alt=""><figcaption></figcaption></figure>

## Provide inputs for the prompts

### **Enter your tenant ID**

Follow the steps below to find your tenant ID:

1. Type “**App registrations**" in the [Azure portal](https://portal.azure.com) search bar and select said option as it appears.

   <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-de39a01ed0c1a62373441249818a900908adc623%2F14.1.png?alt=media" alt=""><figcaption></figcaption></figure>
2. Find and select the application registration [previously created](https://maqsoftware.gitbook.io/pbi-load-analyzer-technical-documentation/setting-up/pre-deployment/create-an-app-registration-for-the-loadfast-api#create-an-app-registration) for the LoadFAST API on the list.

   <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-7c2746b218e54db0eb1ca9501a29f2f07799aa47%2F7.5.png?alt=media" alt=""><figcaption></figcaption></figure>
3. This takes you to its summary page where you can find the directory (tenant) ID and copy it directly to your clipboard.

   <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-7dd669871a93aea5e45739f4c27e06aca9150a20%2F13.13.png?alt=media" alt=""><figcaption></figcaption></figure>
4. In the PowerShell terminal, paste/enter the subscription ID from the previous step.

### **Enter your subscription ID**

Follow the steps below to find your subscription ID:

1. Type “**Resource groups**" in the [Azure portal](https://portal.azure.com) search bar and select said option as it appears.

   <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-928f2fd976e27fcaa8edc89f1e414e35b408721a%2F14.2.png?alt=media" alt=""><figcaption></figcaption></figure>
2. Once on the page, you will see a list of resource groups displayed. Select the resource group where you want to deploy the tool resources to. This can be resource group

   <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-dc08d10c8809f6a9d362dd3ea80dffd6f15dff3c%2F14.7.png?alt=media" alt=""><figcaption></figcaption></figure>
3. Copy the subscription ID as shown below.

   <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-712f77e6a9775e07475ef06688911c93b13ce13a%2F13.14.png?alt=media" alt=""><figcaption></figcaption></figure>
4. In the PowerShell terminal, paste/enter the subscription ID from the previous step.

### **Enter your resource group name**

1. Type “Resource groups" in the Azure portal search bar and select said option as it appears.

   <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-928f2fd976e27fcaa8edc89f1e414e35b408721a%2F14.2.png?alt=media" alt=""><figcaption></figcaption></figure>
2. Once on the page, you will see a list of resource groups displayed. Select the resource group that you have used [earlier](https://app.gitbook.com/o/y5GtRZWy1TmKHu51iTFD/s/3Am7TO0x29a6l1P0wMUg/setting-up/deployment/deploy-automatically-via-azure-marketplace#create-a-managed-application) to create the managed application.

   <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-dc08d10c8809f6a9d362dd3ea80dffd6f15dff3c%2F14.7.png?alt=media" alt=""><figcaption></figcaption></figure>
3. Find and select the managed application as shown in the image below:\\

   <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-4dfcf3038789ba615021df0d50e71b0c8aa95fe0%2F14.3.png?alt=media" alt=""><figcaption></figcaption></figure>
4. Copy the name of the managed resource group.

<figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-ff0db23988f50002c8b1afcc819c78961558a551%2F14.8.png?alt=media" alt=""><figcaption></figcaption></figure>

5. Paste/enter the managed resource group name in the PowerShell terminal like the previous steps.

### **Log into Azure through the PowerShell pop-up window**

If already logged into Azure, it will ask you to pick an account. If not, then you need to sign in with your Azure account.

<figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-14758ff1876d381491772763ae3bf9becb8337be%2F13.16.png?alt=media" alt=""><figcaption></figcaption></figure>

## Other details

* See the output and any actions performed by the script in the console pane at the bottom of the PowerShell window.

  <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-ba9251428f492088ed00d137feb7e19a626c62db%2F13.17.png?alt=media" alt=""><figcaption></figcaption></figure>
* To verify the backend deployment, follow these steps:
  1. Type “**Kubernetes services**" in the Azure portal search bar and select said option as it appears.

     <figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-8a8b31ec097c54fbe5762e794a8c218fefe918d7%2F15.1.png?alt=media" alt=""><figcaption></figcaption></figure>
  2. Once on the page, you will see a list of Kubernetes clusters displayed. Select the Kubernetes cluster created for your web app (more information regarding cluster name detailed in the note).

{% hint style="info" %}
**Note:** Kubernetes clusters are automatically created and named as follows: "**WebAppName**\_AksCluster".

In our case, our web app was named "**powerbiloadanalyzer**" (as seen in step 4 of this [process](https://maqsoftware.gitbook.io/pbi-load-analyzer-technical-documentation/setting-up/deployment/deploy-automatically-via-azure-marketplace#create-a-managed-application)). Thus, our Kuberenetes cluster name is "powerbiloadanalyzer\_AksCluster".
{% endhint %}

<figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-ebffdfc1ae463d13aef4aa7384b0b17d6fe663a2%2F15.5.png?alt=media" alt=""><figcaption></figcaption></figure>

3. Select **Workloads** (under Kubernetes resources) from the left pane.

<figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-a473f706eef0e87b81e8f53ac5cd4f928fc8800c%2F15.2.png?alt=media" alt=""><figcaption></figcaption></figure>

4. Under the **Deployments** tab, you can see all the deployments. Ensure that they all have a green tick in the **Ready** column.

<figure><img src="https://2147433183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Am7TO0x29a6l1P0wMUg%2Fuploads%2Fgit-blob-75ed361f08e626d9a578b5fb9be444e7f3b92337%2F13.18.png?alt=media" alt=""><figcaption></figcaption></figure>
