[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Make User Choose from Output

Posted on 2013-01-31
3
Medium Priority
?
278 Views
Last Modified: 2013-01-31
I have this script:

# Technical Documentation Here: http://www.netsupportsoftware.com/Support/kb/asp/kbprovider.asp?gettd=298&lang=EN&xsl=http%3A//www.netsupportsoftware.com/Support/kb/TechDoc.xsl
Add-PSSnapin Quest.ActiveRoles.ADManagement

$User= read-host "What is the firstname,last name, or Username of the user?"
$ComputerName = Get-QADComputer -ManagedBy (Get-QADUser $User)
$Computer=$Computer.Name


while ((Test-Connection -Quiet -ComputerName $Computer) -eq $False) {Test-Connection -Quiet -ComputerName $Computer}

if ((Test-Connection -Quiet -ComputerName $Computer) -eq $True) {
& 'C:\Program Files (x86)\NetSupport\NetSupport Manager\PCICTLUI.EXE' /C"$Computer" /vw /e
}

pause

Open in new window


It prompts for a username and searches AD for that username. It then returns a list of computers.

If only a single computer is returned, it will ping that computer and start a remote connection to that computer. If the computer is off, it will continue to ping until it is turned on.

When multiple computers are returned, I get a lot of errors because of the $Computer variable. How can I prompt the user to choose between the list computers and then input their choice into the $Computer variable?
0
Comment
Question by:Joseph Moody
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 16

Assisted Solution

by:Rajitha Chimmani
Rajitha Chimmani earned 200 total points
ID: 38840420
You may try adding a foreach loop irrespective of single or multiple computers...something like this

# Technical Documentation Here: http://www.netsupportsoftware.com/Support/kb/asp/kbprovider.asp?gettd=298&lang=EN&xsl=http%3A//www.netsupportsoftware.com/Support/kb/TechDoc.xsl
Add-PSSnapin Quest.ActiveRoles.ADManagement

$User= read-host "What is the firstname,last name, or Username of the user?"
$Computers = Get-QADComputer -ManagedBy (Get-QADUser $User)

foreach($Computer in $Computers){
$ComputerName = $Computer.Name
while ((Test-Connection -Quiet -ComputerName $ComputerName) -eq $False) {Test-Connection -Quiet -ComputerName $ComputerName}

if ((Test-Connection -Quiet -ComputerName $ComputerName) -eq $True) {
& 'C:\Program Files (x86)\NetSupport\NetSupport Manager\PCICTLUI.EXE' /C"$ComputerName" /vw /e
}
}

Open in new window

0
 
LVL 40

Accepted Solution

by:
Subsun earned 1800 total points
ID: 38840435
Try
# Technical Documentation Here: http://www.netsupportsoftware.com/Support/kb/asp/kbprovider.asp?gettd=298&lang=EN&xsl=http%3A//www.netsupportsoftware.com/Support/kb/TechDoc.xsl
Add-PSSnapin Quest.ActiveRoles.ADManagement

Function Run-PCICTLUI
{
while ((Test-Connection -Quiet -ComputerName $Computer) -eq $False) {Test-Connection -Quiet -ComputerName $Computer}

if ((Test-Connection -Quiet -ComputerName $Computer) -eq $True) {
& 'C:\Program Files (x86)\NetSupport\NetSupport Manager\PCICTLUI.EXE' /C"$Computer" /vw /e
}

pause
}

$User= read-host "What is the firstname,last name, or Username of the user?"
$ComputerName = Get-QADComputer -ManagedBy (Get-QADUser $User)

If (($ComputerName | Measure-Object).Count -gt 1){
$ComputerName | Select Name
$Computer = read-host "Type the correct Computer Name from list"
Run-PCICTLUI
}
Else{
$Computer = $ComputerName.name
Run-PCICTLUI
}

Open in new window

0
 
LVL 22

Author Closing Comment

by:Joseph Moody
ID: 38840455
Thank you! I learn so much from you guys!
0

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question