PowerShell script that prompts the user for the object name

robert-v-ruggiero-BG-iyXjJiLs-unsplash

Sure, here's a PowerShell script that prompts the user for the object name and type, searches for that object, and then displays the details of the selected object in Active Directory on a Windows Server:

# Import the Active Directory module
Import-Module ActiveDirectory

# Prompt the user for the object name and type
$objectName = Read-Host "Enter the name of the object you want to search for"
$objectType = Read-Host "Enter the type of the object you want to search for"

# Search for the object
$objects = Get-ADObject -Filter {Name -like $objectName -and ObjectClass -eq $objectType}

# Display the object being searched for
Write-Output "Searching for $objectType with name like $objectName"

# Let the user select the object to display details for
$selectedObject = $objects | Out-GridView -PassThru

# Display the details of the selected object
Get-ADObject $selectedObject -Properties * 

 When you run this script, it will prompt you for the name and type of the object you want to search for. Once you enter those details, it will search for the object and display the object being searched for. It will then open a window where you can select the object you want to display details for. Once you select an object, it will display all the details of that object in Active Directory on the Windows Server.


Font size: +
Report Print
 

By accepting you will be accessing a service provided by a third-party external to https://www.klokur.com/