Announcement

Collapse
No announcement yet.

variable output does not appear on 2nd loop

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • variable output does not appear on 2nd loop

    Hi

    I have created a script to query user info. The whole script is to loop, purpose being to choose another user when finished.

    all variables are cleared at end of running 1st loop

    weird thing is on running the 2nd time/loop all the variables bar 1 show their data/contents.

    only below is displayed the 1st run but not the 2nd !
    $useraddetails | select,name,samaccountname

    instead i get {} {} or a blank space.

    Any idea why this could be ?

    for testing on the 2nd Ioop. I did break the script near the end (before it had a chance to clear the variables) and ran $useraddetails | select,name,samaccountname
    and it outputted the correct user from the powershell CLI just fine. so why not then from the script !?

    Thanks

    Confuseis



  • #2
    Can you post the entire script please (use CODE tags or attach as a text file) as without it we cannot help very much
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Hi

      Ive attached that script file

      the variable $chosenuser under the ==== User Account === displays fine until the script is ran again when the user chooses S to search again foir another user

      When searching for another user the variable $chosenuser is not displayed. It only displays on the 1st loop.

      Thanks
      Attached Files

      Comment


      • #4

        Below was the culprit Get-ADPrincipalGroupMembership $pick.samaccountname | select name | format-wide I have removed the format-wide section at the end and now the other variables are unaffected by It. Dont know why this is but that worked.

        Comment

        Working...
        X