ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Powershell Get-Childitem behavior with variables

    IT Discussion
    windows server 2012 r2 powershell scripting
    5
    11
    2.0k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      EddieJennings
      last edited by

      Two more tidbits.

      This happens even when running as the system account. If I run an elevated command prompt and run psexec.exe -i -s -accepteula powershell.exe to get a PowerShell session as System, the behavior persists.

      I have found what appears to be a workaround: Use -OutVariable foo at the end of the command. This still lists all of the results of Get-ChildItem for me, but at least it did also store it in a variable.

      1 Reply Last reply Reply Quote 0
      • E
        EddieJennings
        last edited by

        More information from experimenting.

        Using Out-variable doesn't actually make much of a different. Error is still occurring (didn't notice it the first time).

        Also, apparently the command with no variable is having access problems. Methinks now there's something screwy with this particular server.

        D 1 Reply Last reply Reply Quote 0
        • J
          jmoore
          last edited by

          That could be Eddie. I'm experimenting and checking behavior with some of these commands.

          1 Reply Last reply Reply Quote 0
          • D
            dafyre @EddieJennings
            last edited by

            @eddiejennings said in Powershell Get-Childitem behavior with variables:

            More information from experimenting.

            Using Out-variable doesn't actually make much of a different. Error is still occurring (didn't notice it the first time).

            Also, apparently the command with no variable is having access problems. Methinks now there's something screwy with this particular server.

            Do you still get the access issues if you're running powershell as admin?

            E 1 Reply Last reply Reply Quote 0
            • E
              EddieJennings @dafyre
              last edited by

              @dafyre said in Powershell Get-Childitem behavior with variables:

              @eddiejennings said in Powershell Get-Childitem behavior with variables:

              More information from experimenting.

              Using Out-variable doesn't actually make much of a different. Error is still occurring (didn't notice it the first time).

              Also, apparently the command with no variable is having access problems. Methinks now there's something screwy with this particular server.

              Do you still get the access issues if you're running powershell as admin?

              Yes. Logged in as the local administrator account, as well as running as admin (which is the only option for this account).

              J 1 Reply Last reply Reply Quote 0
              • J
                jmoore @EddieJennings
                last edited by

                @eddiejennings I assume you also right clicked and selected to [run as administrator]?
                My account is an admin also but if i don't do the above some things don't work.

                E 1 Reply Last reply Reply Quote 1
                • M
                  momurda
                  last edited by

                  This is likely because "Documents and Settings" isnt a real folder, just a junction point since Windows 7/Server 2008. Same reason you usually cant open this folder in Explorer.
                  These shortcuts only exist for legacy Windows things to function. You wont find this fake folder in Windows 10.

                  1 Reply Last reply Reply Quote 1
                  • B
                    black3dynamite
                    last edited by black3dynamite

                    It probably has something to do with it being a junction point.

                    cmd /c "dir /al" will show that its a junction point to C:\Users

                    1 Reply Last reply Reply Quote 1
                    • E
                      EddieJennings @jmoore
                      last edited by

                      @jmoore said in Powershell Get-Childitem behavior with variables:

                      @eddiejennings I assume you also right clicked and selected to [run as administrator]?
                      My account is an admin also but if i don't do the above some things don't work.

                      I did.

                      1 Reply Last reply Reply Quote 0
                      • E
                        EddieJennings
                        last edited by

                        Must've been that one server. Seems like it's running fine on another one.

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post