Questions tagged [read-host]

Read-Host is PowerShell's cmdlet for requesting a line of input from the user.

28 questions
0
votes
1 answer

Read-host not passing variable?

So I writing some code to run some patching on AWS, I have the following script snippet taken out of the whole thing for now.. I seem to be running into an issue with $PSBoundParameters.. (It's Friday & I've had a long week so I may just need to…
Alex
  • 29
  • 5
0
votes
1 answer

Powershell script to Stop and start windows Service using S.no

I have a listed my Windows Service Names in the Text file and I have added the code to display it by adding the S.no preceding to the Names, Listofservices.txt contains Print Spooler Windows Update Remote Desktop Services Get-Content…
karhtik
  • 506
  • 3
  • 15
0
votes
1 answer

Read-Host Printing the data if the input is given from file | Ubuntu 16

I am experiencing issues with Read-Host when I am trying to read input from file Let's say I create a file read.pwsh having the following contents $a = Read-Host; and there is input file input.in having the following content hello After executing…
rjohari23
  • 119
  • 9
0
votes
1 answer

Read-Host list of filenames and then export the Input to a csv file

I am trying to do a simply read host and export the user input to a csv file. $List = Read-Host -Prompt 'Enter List of files (exclude file extention)'| Export-Csv "c:\user.csv" -NoTypeInformation All I get in my file is: "length" "42" I think I…
Harry123
  • 49
  • 7
0
votes
0 answers

Powershell Multiple string read-console

Right now I have a script that cycles through different AD users and groups that are manually assigned. I would love to be able to do a read-console but I don't know how to get to ask for multiple strings, when I don't know how many strings there…
aric8456
  • 129
  • 2
  • 11
0
votes
1 answer

Changing a variable based on output

Good Afternoon, Just want to start by saying I am totally new with PS, and am really sorry if my approach to this is long winded or inaccurate. I have a list of computernames that declared as individual Variables that my colleagues have provided me…
0
votes
1 answer

[string[]] Parameter vs Read-Host behaviour

Within my PowerShell script I have parameter set for : [string[]]$OptionNum So I can call my script using for instance : .\MyScript.ps1 1,4,6 I then have a switch statement on $OptionNum for PSItem –contains “n” with each option value, to run the…
Keith Langmead
  • 785
  • 1
  • 5
  • 16
0
votes
1 answer

Powershell: Read-Host to select an Array Index

This is how I modify my Powershell array: ForEach ($userID in $usersList) { $allUsers +=…
GameX
  • 5
  • 4
0
votes
0 answers

Is there a way to get user input to Powershell's Read-Host from PHP?

I have a Powershell script which I'm trying to implement on a website with PHP's shell_exec. The script will usually complete on it's own without the need for user input. However in some rare cases, user input is needed. Read-Host is good when…
Erik Erik
  • 45
  • 5
0
votes
2 answers

Is there any way or method to figure out my mistake to get solution for this command?

I type this Powershell command PS C:\Users\User> new-aduser -name "Tracy Jones" -givenname "Tracy" -surname "Jones" -samaccountname "tjones" userprincipalname "tjones@adatum.com" -path "ou=marketing,dc=abc,dc=com" -accountpassword(-Read-Host…
0
votes
1 answer

Do Until loop by Restricting user input to email address or domain\ID in PowerShell using Read-Host

Im doing a Do Until loop by Restricting user input to email address or domain\ID in PowerShell using Read-Host. The condition is not working. Original syntax: do { $answer = Read-Host "yes or no" } until ("yes","no" -contains $answer) Input: $DL1 =…
HGB 85
  • 3
  • 2
0
votes
1 answer

How can I increase the maximum number of characters read by Read-Host?

I need to get a very long string input (around 9,000 characters), but Read-Host will truncate after around 8,000 characters. How can I extend this limit?
xinglong
  • 115
  • 1
  • 5
0
votes
1 answer

Powershell Get-mailboxdatabase and Create Shared Mailbox Script

I have some basic Powershell knowledge and i am trying to revise an existing script on our Service Desk to make a shared mailbox in Exchange 2010. The current version was setup so the user can input the database to assign the mailbox to. The…
1
2