Noyha56

Forum Replies Created

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • in reply to: [POWERSHELL] Read-Host priority #231289
    Participant
    Topics: 3
    Replies: 7
    Points: 37
    Rank: Member

    I just tried and that doesn’t work too the display is always after the read-Host

     

    EDIT : I found a way to bypass the problem I have added another Read-Host before the first that doesn’t resolve the problem but that allow to bypass it.

    • This reply was modified 2 months, 1 week ago by Noyha56.
    in reply to: [POWERSHELL] Read-Host priority #231274
    Participant
    Topics: 3
    Replies: 7
    Points: 37
    Rank: Member

    Do write-information or write-verbose instead of write-host

    I tried the two of them but no one work there is no way to resolve it or we can’t use a similar fonction of Read-Host ?

    in reply to: [POWERSHELL] Read-Host priority #231178
    Participant
    Topics: 3
    Replies: 7
    Points: 37
    Rank: Member

    I think perhaps it is something similar to write-host. Write-host goes directly to the console, which can make it show up before other write-output commands that were executed long before write-host. Take this example

    PowerShell
    3 lines

     

    1
    2
    3
    write-output (get-date | select * | gm)
    write-host “test”
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    When the command write-output is called, it takes a split second to calculate the output. Therefore the actual output shows up reverse of the order one might expect.

    PowerShell
    25 lines

     

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    test
    TypeName: Selected.System.DateTime
    Name MemberType Definition
    —- ———- ———-
    Equals Method bool Equals(System.Object obj)
    GetHashCode Method int GetHashCode()
    GetType Method type GetType()
    ToString Method string ToString()
    Date NoteProperty datetime Date=2020-05-26 12:00:00 AM
    DateTime NoteProperty System.String DateTime=Tuesday, May 26, 2020 2:27:37 PM
    Day NoteProperty int Day=26
    DayOfWeek NoteProperty DayOfWeek DayOfWeek=Tuesday
    DayOfYear NoteProperty int DayOfYear=147
    DisplayHint NoteProperty DisplayHintType DisplayHint=DateTime
    Hour NoteProperty int Hour=14
    Kind NoteProperty DateTimeKind Kind=Local
    Millisecond NoteProperty int Millisecond=886
    Minute NoteProperty int Minute=27
    Month NoteProperty int Month=5
    Second NoteProperty int Second=37
    Ticks NoteProperty long Ticks=637261000578866934
    TimeOfDay NoteProperty timespan TimeOfDay=14:27:37.8866934
    Year NoteProperty int Year=2020
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    As opposed to this

    PowerShell
    6 lines

     

    1
    2
    3
    4
    5
    6
    write-output (get-date)
    write-host “test”
    Tuesday, May 26, 2020 2:32:24 PM
    test
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    If this is the case, perhaps you can assign it to a variable and then output it when you’re ready. (just remember write-host nuance)

    PowerShell
    3 lines

     

    1
    2
    3
    $userinput = Read-Host Prompt “Enter some input”
    write-host $userinput
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Yes that is exactly the problem the Read-Host is realized before my Table but when I enter any character when the Read-Host ask i Have in first what I have typing when the Read-Host asking me and in the second my table that is exactly the exemple that you give with Write-Host.

    But I tried to do :

    $choice = Read-Host -Prompt “test verify display :”

    Write-Host $choice

    But that doesn’t fix the problem like you said there is always the nuance

     

    in reply to: [POWERSHELL] Read-Host priority #231097
    Participant
    Topics: 3
    Replies: 7
    Points: 37
    Rank: Member

    Are you trying to display a comment before the Read-Host?

    PowerShell
    5 lines

    <textarea class=”ace_text-input” style=”opacity: 0; height: 18px; width: 6.59781px; left: 44px; top: 0px;” spellcheck=”false” wrap=”off”></textarea>

    1
    2
    3
    4
    5
    $table =[pscustomobject]@{Commentaire = ‘This is my content’}
    $table.Commentaire
    Read-Host “What is up?”
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Output:

    PowerShell
    4 lines

    <textarea class=”ace_text-input” style=”opacity: 0; height: 18px; width: 6.59781px; left: 44px; top: 0px;” spellcheck=”false” wrap=”off”></textarea>

    1
    2
    3
    4
    This is my content
    What is up?: The sky
    The sky
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Or you can additionally concatenate the string with line breaks:

    PowerShell
    7 lines

    <textarea class=”ace_text-input” style=”opacity: 0; height: 18px; width: 6.59781px; left: 44px; top: 0px;” spellcheck=”false” wrap=”off”></textarea>

    1
    2
    3
    4
    5
    6
    7
    Read-Host (“{0}rnrnWhat is up?” -f $table.Commentaire)
    This is my content
    What is up?: The moon
    The moon
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I’m trying to display the comment in a file .txt in my array like this picture ( random pic on google) :

    But my comment is put instead of User1, User2….

     

    I tried to put my code before the read-Host but it pass in first i don’t know why.

    The last solution that you propose don’t correspond for what I want because i want to display $Table before read-Host so i can’t concatenateI think

    • This reply was modified 2 months, 2 weeks ago by Noyha56.
    • This reply was modified 2 months, 2 weeks ago by Noyha56.
    Participant
    Topics: 3
    Replies: 7
    Points: 37
    Rank: Member

    Thanks for the help i gonna try that

    in reply to: [POWERSHELL] check rename directory #227602
    Participant
    Topics: 3
    Replies: 7
    Points: 37
    Rank: Member

    Thanks for your help I’ll test this method tomorrow !

    in reply to: [POWERSHELL] check rename directory #227578
    Participant
    Topics: 3
    Replies: 7
    Points: 37
    Rank: Member

    Explain and show all of the code. What is $test? You should not need to see if something is renamed as you should be only finding folders named ‘exemple’ to do the rename.

    The code is just about a directory which is in a place and I want to rename this directory. As soon as it’s rename I want to do a conditionnal “If “to verify if the directoy is correctly rename.

    The variable $test is a random name for my example $test can be equal to “C:\User\Program” It’s just the place where we can find the directory that we want to rename

Viewing 7 posts - 1 through 7 (of 7 total)