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

    Powershell Default User

    IT Discussion
    powershell
    5
    26
    2.1k
    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.
    • dbeatoD
      dbeato
      last edited by

      @lakshmana said in Powershell Default User:

      fault or current user in the Powershell. Like in .bat file we can mention C:%username%\

      More info here:
      https://technet.microsoft.com/en-us/library/ff730963.aspx

      LakshmanaL 1 Reply Last reply Reply Quote 0
      • LakshmanaL
        Lakshmana @dbeato
        last edited by

        @dbeato
        Param (
        [string]$file = 'C:%USERNAME%\fILENAME'
        )

        in my powershell how to rename here ?

        dbeatoD 1 Reply Last reply Reply Quote 0
        • dbeatoD
          dbeato @Lakshmana
          last edited by

          @lakshmana said in Powershell Default User:

          @dbeato
          Param (
          [string]$file = 'C:%USERNAME%\fILENAME'
          )

          in my powershell how to rename here ?

          Param (
          [string]$file = 'C:\$env:UserName\fILENAME'
           )
          LakshmanaL 1 Reply Last reply Reply Quote 0
          • LakshmanaL
            Lakshmana @dbeato
            last edited by

            @dbeato said in Powershell Default User:

            [string]$file = 'C:$env:UserName\fILENAME'
            )

            Get-Item : Cannot find path 'C:$env:Username\Tickets' because it does not exist.

            dbeatoD black3dynamiteB 2 Replies Last reply Reply Quote 0
            • dbeatoD
              dbeato @Lakshmana
              last edited by

              @lakshmana said in Powershell Default User:

              @dbeato said in Powershell Default User:

              [string]$file = 'C:$env:UserName\fILENAME'
              )

              Get-Item : Cannot find path 'C:$env:Username\Tickets' because it does not exist.

              Can you declare it before the string then into a variable?

              1 Reply Last reply Reply Quote 0
              • black3dynamiteB
                black3dynamite @Lakshmana
                last edited by

                @lakshmana said in Powershell Default User:

                @dbeato said in Powershell Default User:

                [string]$file = 'C:$env:UserName\fILENAME'
                )

                Get-Item : Cannot find path 'C:$env:Username\Tickets' because it does not exist.

                It should be 'C:\Users\$env:USERNAME\filename'

                dbeatoD 1 Reply Last reply Reply Quote 2
                • dbeatoD
                  dbeato @black3dynamite
                  last edited by

                  @black3dynamite said in Powershell Default User:

                  @lakshmana said in Powershell Default User:

                  @dbeato said in Powershell Default User:

                  [string]$file = 'C:$env:UserName\fILENAME'
                  )

                  Get-Item : Cannot find path 'C:$env:Username\Tickets' because it does not exist.

                  It should be 'C:\Users\$env:USERNAME\filename'

                  That's right...

                  LakshmanaL 1 Reply Last reply Reply Quote 0
                  • LakshmanaL
                    Lakshmana @dbeato
                    last edited by

                    @dbeato said in Powershell Default User:

                    @black3dynamite said in Powershell Default User:

                    @lakshmana said in Powershell Default User:

                    @dbeato said in Powershell Default User:

                    [string]$file = 'C:$env:UserName\fILENAME'
                    )

                    Get-Item : Cannot find path 'C:$env:Username\Tickets' because it does not exist.

                    It should be 'C:\Users\$env:USERNAME\filename'

                    That's right...

                    Get-Item : Cannot find path 'C:\Users$env:USERNAME\filename' because it does not exist.

                    scottalanmillerS black3dynamiteB 2 Replies Last reply Reply Quote 0
                    • scottalanmillerS
                      scottalanmiller @Lakshmana
                      last edited by

                      @lakshmana said in Powershell Default User:

                      @dbeato said in Powershell Default User:

                      @black3dynamite said in Powershell Default User:

                      @lakshmana said in Powershell Default User:

                      @dbeato said in Powershell Default User:

                      [string]$file = 'C:$env:UserName\fILENAME'
                      )

                      Get-Item : Cannot find path 'C:$env:Username\Tickets' because it does not exist.

                      It should be 'C:\Users\$env:USERNAME\filename'

                      That's right...

                      Get-Item : Cannot find path 'C:\Users$env:USERNAME\filename' because it does not exist.

                      Still missing the \

                      LakshmanaL dbeatoD 2 Replies Last reply Reply Quote 0
                      • LakshmanaL
                        Lakshmana @scottalanmiller
                        last edited by

                        @scottalanmiller Its already there when i am copy pasting its not showing

                        scottalanmillerS 1 Reply Last reply Reply Quote 0
                        • dbeatoD
                          dbeato @scottalanmiller
                          last edited by

                          @scottalanmiller said in Powershell Default User:

                          @lakshmana said in Powershell Default User:

                          @dbeato said in Powershell Default User:

                          @black3dynamite said in Powershell Default User:

                          @lakshmana said in Powershell Default User:

                          @dbeato said in Powershell Default User:

                          [string]$file = 'C:$env:UserName\fILENAME'
                          )

                          Get-Item : Cannot find path 'C:$env:Username\Tickets' because it does not exist.

                          It should be 'C:\Users\$env:USERNAME\filename'

                          That's right...

                          Get-Item : Cannot find path 'C:\Users$env:USERNAME\filename' because it does not exist.

                          Still missing the \

                          If you quote it, it shows. I am not sure if it is a bug on NodeBB.

                          1 Reply Last reply Reply Quote 0
                          • scottalanmillerS
                            scottalanmiller @Lakshmana
                            last edited by

                            @lakshmana said in Powershell Default User:

                            @scottalanmiller Its already there when i am copy pasting its not showing

                            Oh, you have to escape it.

                            1 Reply Last reply Reply Quote 0
                            • dbeatoD
                              dbeato
                              last edited by

                              This is a small sample I did and it worked:
                              0_1514696665902_DeepinScreenshot_select-area_20171231000315.png

                              1 Reply Last reply Reply Quote 0
                              • scottalanmillerS
                                scottalanmiller
                                last edited by

                                Are you sure that the filename exists?

                                LakshmanaL 1 Reply Last reply Reply Quote 0
                                • dbeatoD
                                  dbeato
                                  last edited by

                                  Better example:
                                  0_1514696738887_DeepinScreenshot_select-area_20171231000518.png

                                  1 Reply Last reply Reply Quote 0
                                  • LakshmanaL
                                    Lakshmana @scottalanmiller
                                    last edited by

                                    @scottalanmiller said in Powershell Default User:

                                    Are you sure that the filename exists?

                                    The files exists inside that folder and before doing this i have mentioned as in .bat but that has to runned in the all the machine means it should get the current user details so only asked for the same which is not working when tried to execute in the powershell

                                    dbeatoD 1 Reply Last reply Reply Quote 0
                                    • dbeatoD
                                      dbeato @Lakshmana
                                      last edited by

                                      @lakshmana said in Powershell Default User:

                                      @scottalanmiller said in Powershell Default User:

                                      Are you sure that the filename exists?

                                      The files exists inside that folder and before doing this i have mentioned as in .bat but that has to runned in the all the machine means it should get the current user details so only asked for the same which is not working when tried to execute in the powershell

                                      So are you running this via a task or when the user logs in?

                                      LakshmanaL 1 Reply Last reply Reply Quote 0
                                      • black3dynamiteB
                                        black3dynamite @Lakshmana
                                        last edited by

                                        @lakshmana said in Powershell Default User:

                                        @dbeato said in Powershell Default User:

                                        @black3dynamite said in Powershell Default User:

                                        @lakshmana said in Powershell Default User:

                                        @dbeato said in Powershell Default User:

                                        [string]$file = 'C:$env:UserName\fILENAME'
                                        )

                                        Get-Item : Cannot find path 'C:$env:Username\Tickets' because it does not exist.

                                        It should be 'C:\Users\$env:USERNAME\filename'

                                        That's right...

                                        Get-Item : Cannot find path 'C:\Users$env:USERNAME\filename' because it does not exist.

                                        C:\$env:Username\Tickets should be 'C:\Users\$env:USERNAME\Tickets'

                                        LakshmanaL 1 Reply Last reply Reply Quote 0
                                        • LakshmanaL
                                          Lakshmana @black3dynamite
                                          last edited by

                                          @black3dynamite said in Powershell Default User:

                                          @lakshmana said in Powershell Default User:

                                          @dbeato said in Powershell Default User:

                                          @black3dynamite said in Powershell Default User:

                                          @lakshmana said in Powershell Default User:

                                          @dbeato said in Powershell Default User:

                                          [string]$file = 'C:$env:UserName\fILENAME'
                                          )

                                          Get-Item : Cannot find path 'C:$env:Username\Tickets' because it does not exist.

                                          It should be 'C:\Users\$env:USERNAME\filename'

                                          That's right...

                                          Get-Item : Cannot find path 'C:\Users$env:USERNAME\filename' because it does not exist.

                                          C:\$env:Username\Tickets should be 'C:\Users\$env:USERNAME\Tickets'

                                          I have changed already

                                          1 Reply Last reply Reply Quote 0
                                          • LakshmanaL
                                            Lakshmana @dbeato
                                            last edited by

                                            @dbeato said in Powershell Default User:

                                            @lakshmana said in Powershell Default User:

                                            @scottalanmiller said in Powershell Default User:

                                            Are you sure that the filename exists?

                                            The files exists inside that folder and before doing this i have mentioned as in .bat but that has to runned in the all the machine means it should get the current user details so only asked for the same which is not working when tried to execute in the powershell

                                            So are you running this via a task or when the user logs in?

                                            This is the powershell which converts into .csv to .xlsx in the machine in the folder mentioned

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