Solved

Make User Choose from Output

Posted on 2013-01-31
3
251 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
3 Comments
 
LVL 16

Assisted Solution

by:Rajitha Chimmani
Rajitha Chimmani earned 50 total points
Comment Utility
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 450 total points
Comment Utility
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 21

Author Closing Comment

by:Joseph Moody
Comment Utility
Thank you! I learn so much from you guys!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
Set OWA language and time zone in Exchange for individuals, all users or per database.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now