Powershell Add Windows Device To Intune

6 min read Oct 03, 2024
Powershell Add Windows Device To Intune

PowerShell: Adding Windows Devices to Intune

Microsoft Intune is a powerful cloud-based solution for managing and securing your organization's devices, including Windows computers. PowerShell is a scripting language that allows you to automate many tasks within Windows, including enrolling devices in Intune. This article will guide you through the process of adding Windows devices to Intune using PowerShell.

What is Intune and Why Use It?

Intune helps you manage your company's devices and applications. This includes tasks like:

  • Device enrollment: Adding devices to Intune management
  • App management: Deploying and managing apps on devices
  • Security policies: Setting up security configurations and restrictions
  • Updates: Keeping devices up-to-date with the latest software
  • Data protection: Securing company data on devices

Prerequisites

Before we begin, ensure that you have the following:

  • A Microsoft Intune subscription: Intune is a paid service from Microsoft. You will need a subscription to use it.
  • A Windows device: The device you want to enroll in Intune.
  • PowerShell: The PowerShell module for Intune needs to be installed on your device.
  • An Intune administrator account: This account has the necessary permissions to manage Intune.

Steps to Add Windows Devices to Intune

  1. Install the Intune PowerShell Module:

    • Open PowerShell as an administrator.
    • Run the following command to install the Intune module:
      Install-Module -Name Microsoft.Intune
      
  2. Connect to Intune:

    • Open a new PowerShell session and run the following command to connect to your Intune tenant:
      Connect-MicrosoftIntune
      
    • You will be prompted for your Intune administrator credentials.
  3. Generate a Device Enrollment Token:

    • Run the following command to generate a device enrollment token. This token will be used by the device to enroll itself in Intune:
      New-IntuneDeviceEnrollmentToken -Name "YourTokenName" -Description "Token for enrollment" -DurationInDays 30 -AllowedPlatform Windows
      
      • Replace "YourTokenName" with a descriptive name for the token.
      • The DurationInDays parameter specifies how long the token will be valid.
      • The AllowedPlatform parameter specifies the platform for which the token is valid.
  4. Enroll the Device:

    • On the device you want to enroll, open a browser and navigate to the device enrollment URL. This URL will be provided in the output of the New-IntuneDeviceEnrollmentToken command.
    • Enter the device enrollment token and follow the onscreen instructions to complete the enrollment process.

Troubleshooting Tips

  • Check your Intune administrator credentials: Make sure you are using the correct credentials to connect to Intune.
  • Verify the device enrollment token: Double-check that the device enrollment token is entered correctly.
  • Ensure the device is connected to the internet: The device needs to be online to connect to Intune.
  • Check the Intune portal: Log into the Intune portal to see if the device has successfully enrolled.

Example

Here is a complete example of how to add a Windows device to Intune using PowerShell:

# Install the Intune PowerShell module
Install-Module -Name Microsoft.Intune

# Connect to Intune
Connect-MicrosoftIntune

# Generate a device enrollment token
New-IntuneDeviceEnrollmentToken -Name "MyEnrollmentToken" -Description "Token for Windows devices" -DurationInDays 30 -AllowedPlatform Windows

# Open the device enrollment URL on the device and enter the token to enroll

Conclusion

By using PowerShell, you can automate the process of adding Windows devices to Intune, making your device management more efficient. The steps in this article provide a comprehensive guide for successfully enrolling your Windows devices in Intune. Remember to have a solid understanding of your Intune environment and the security implications of enrolling devices before proceeding.