> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/LabtechConsulting/LabTech-Powershell-Module/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Go from zero to a running LabTech agent in five steps using the LabTech PowerShell Module.

This page walks you through importing the module and installing a LabTech agent on a machine for the first time. Every command must be run in an **Administrator** PowerShell session.

<Warning>
  The module installs Windows services and writes to `HKLM:\SOFTWARE\LabTech`. You must run PowerShell as Administrator or every service-management command will throw: *"Needs to be ran as Administrator"*.
</Warning>

<Steps>
  <Step title="Import the module">
    The fastest way to load the module is to download and execute it directly from the LabTech Consulting shortlink. No file is saved to disk; the module is loaded into the current session only.

    ```powershell theme={null}
    (New-Object Net.WebClient).DownloadString('https://bit.ly/LTPoSh') | iex
    ```

    <Note>
      This command evaluates the module source in-memory. If you need to load it from a local file instead, see the [Installation](/installation) page.
    </Note>
  </Step>

  <Step title="Verify the module loaded">
    Confirm the module is available by pulling the current agent registry information. If the agent is not yet installed, the command returns `$null` and emits an informational error — that is expected at this stage.

    ```powershell theme={null}
    Get-LTServiceInfo
    ```

    When no agent is installed you will see:

    ```powershell theme={null}
    Get-LTServiceInfo : ERROR: Line 154: Unable to find information on LTSvc. Make sure the agent is installed.
    ```

    That error confirms the module is loaded and working. To verify the module version directly:

    ```powershell theme={null}
    (Get-Module | Where-Object { $_.Name -like '*LabTech*' }).Version
    ```
  </Step>

  <Step title="Install the agent">
    Call `Install-LTService` with your server URL, server password, and target location ID. The function downloads the agent MSI from your server, runs the installer, and waits up to three minutes for the agent to register.

    ```powershell theme={null}
    Install-LTService -Server 'https://lt.domain.com' `
                      -ServerPassword 'YourServerPassword' `
                      -LocationID 42
    ```

    | Parameter         | Required                         | Description                                                                                                                   |
    | ----------------- | -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
    | `-Server`         | Yes                              | URL of your LabTech server. Bare hostnames and `http://` are also accepted; `https://` is prepended automatically if omitted. |
    | `-ServerPassword` | Yes (or use `-InstallerToken`)   | The server password from `SELECT SystemPassword FROM config;` in the Automate database.                                       |
    | `-LocationID`     | No (defaults to `1`)             | The numeric location ID the agent should appear under.                                                                        |
    | `-InstallerToken` | Alternative to `-ServerPassword` | A deployment token from the Automate Deployment page, for tokenised MSI installs.                                             |

    <Tip>
      Preview what `Install-LTService` would do without executing anything:

      ```powershell theme={null}
      Install-LTService -Server 'https://lt.domain.com' -ServerPassword 'pass' -LocationID 42 -WhatIf
      ```
    </Tip>

    The installer retries the MSI up to three times if `LTService` does not appear after the first run. On success:

    ```
    LabTech has been installed successfully. Agent ID: 1234 LocationID: 42
    ```
  </Step>

  <Step title="Confirm the install succeeded">
    After the installer exits, read the agent's registry values to verify it registered correctly.

    ```powershell theme={null}
    Get-LTServiceInfo
    ```

    Successful output includes the agent ID, server address, and location:

    ```
    ID            : 1234
    LocationID    : 42
    Server        : https://lt.domain.com
    BasePath      : C:\Windows\LTSVC
    ServerVersion : 240.xxx
    ```

    You can also confirm the Windows services are running:

    ```powershell theme={null}
    Get-Service LTService, LTSvcMon | Select-Object Name, Status
    ```

    Both services should report `Running`.
  </Step>

  <Step title="Restart the agent service">
    To restart the agent after a configuration change, use `Restart-LTService`. It stops `LTService` and `LTSvcMon`, waits for the `Stopped` state, then starts both services and waits for `Running`. After startup it automatically sends a `Send Status` command so the agent checks in with the server immediately.

    ```powershell theme={null}
    Restart-LTService
    ```

    On success:

    ```
    Services Restarted successfully.
    ```

    To stop or start services independently:

    ```powershell theme={null}
    Stop-LTService
    Start-LTService
    ```
  </Step>
</Steps>

## Troubleshooting

**Agent installed but did not register within 3 minutes:**

The install completes but `Get-LTServiceInfo` shows no ID. Check that the machine can reach the LabTech server on HTTPS, then restart the agent:

```powershell theme={null}
Restart-LTService
```

**Previous installation remnants detected:**

`Install-LTService` automatically calls `Uninstall-LTService` when it finds leftover files or registry keys under `HKLM:\Software\LabTech\Service` or in `%windir%\LTSVC`. To trigger this manually:

```powershell theme={null}
Uninstall-LTService -Server 'https://lt.domain.com'
```

**Reinstall from scratch:**

`Redo-LTService` reads the current registry settings, uninstalls the agent, and reinstalls it in one command:

```powershell theme={null}
Redo-LTService
```

Or supply parameters explicitly:

```powershell theme={null}
Redo-LTService -Server 'https://lt.domain.com' -ServerPassword 'pass' -LocationID 42
```
